KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > agent > client > LocalForwardingChannelSocket


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.agent.client;
21
22 import java.io.IOException JavaDoc;
23 import java.io.InputStream JavaDoc;
24 import java.io.OutputStream JavaDoc;
25 import java.net.Socket JavaDoc;
26
27 import com.maverick.multiplex.Channel;
28 import com.maverick.multiplex.ChannelOpenException;
29 import com.maverick.multiplex.channels.LocalForwardingChannel;
30
31 class LocalForwardingChannelSocket extends Socket JavaDoc {
32
33     private Channel channel;
34     private Agent agent;
35
36     public LocalForwardingChannelSocket(Agent agent, String JavaDoc host, int port) throws IOException JavaDoc, ChannelOpenException {
37         super();
38         this.agent = agent;
39         channel = new LocalForwardingChannel(host, port);
40         agent.getConnection().openChannel(channel);
41     }
42
43     public LocalForwardingChannelSocket(String JavaDoc host, int port) throws IOException JavaDoc {
44         super(host, port);
45     }
46
47     public InputStream JavaDoc getInputStream() throws IOException JavaDoc {
48         return channel.getInputStream();
49     }
50
51     public OutputStream JavaDoc getOutputStream() throws IOException JavaDoc {
52         return channel.getOutputStream();
53     }
54
55     public synchronized void close() throws IOException JavaDoc {
56         DirectTCPSocketFactory.log.info("Channel socket closed.");
57         channel.close();
58     }
59 }
60
Popular Tags