KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > tunnels > agent > LocalForwardingChannel


1 package com.sslexplorer.tunnels.agent;
2
3 import java.io.IOException JavaDoc;
4
5 import com.maverick.multiplex.ChannelOpenException;
6 import com.maverick.util.ByteArrayReader;
7 import com.sslexplorer.boot.CustomSocketFactory;
8
9 /**
10  * Channel implementation used for <i>Local SSL Tunnels</i>. The channel
11  * makes a socket connection to the provided hostname and port and joins
12  * the channel streams to the socket's streams.
13  *
14  * @author Lee David Painter <a HREF="mailto: lee@3sp.com">&lt;lee@3sp.com&gt;</a>
15  */

16 public class LocalForwardingChannel extends com.maverick.multiplex.channels.LocalForwardingChannel {
17     
18     /**
19      * Constructor.
20      *
21      */

22     public LocalForwardingChannel() {
23         super();
24     }
25
26     /* (non-Javadoc)
27      * @see com.maverick.multiplex.Channel#open(byte[])
28      */

29     public byte[] open(byte[] data) throws IOException JavaDoc , ChannelOpenException{
30         ByteArrayReader msg = new ByteArrayReader(data);
31         this.hostname = msg.readString();
32         this.port = (int) msg.readInt();
33         try {
34             this.socket = CustomSocketFactory.getDefault().createSocket(hostname, port);
35         } catch (IOException JavaDoc ioe) {
36             throw new ChannelOpenException(ChannelOpenException.CONNECT_FAILED, ioe.getMessage());
37         }
38         return null;
39     }
40
41 }
42
Popular Tags