Package com.adito.tunnels.agent

Source Code of com.adito.tunnels.agent.LocalForwardingChannel

package com.adito.tunnels.agent;

import java.io.IOException;

import com.maverick.multiplex.ChannelOpenException;
import com.maverick.util.ByteArrayReader;
import com.adito.boot.CustomSocketFactory;

/**
* Channel implementation used for <i>Local SSL Tunnels</i>. The channel
* makes a socket connection to the provided hostname and port and joins
* the channel streams to the socket's streams.
*/
public class LocalForwardingChannel extends com.maverick.multiplex.channels.LocalForwardingChannel {
 
  /**
   * Constructor.
   *
   */
  public LocalForwardingChannel() {
    super();
  }

  /* (non-Javadoc)
   * @see com.maverick.multiplex.Channel#open(byte[])
   */
  public byte[] open(byte[] data) throws IOException , ChannelOpenException{
    ByteArrayReader msg = new ByteArrayReader(data);
    this.hostname = msg.readString();
    this.port = (int) msg.readInt();
        try {
            this.socket = CustomSocketFactory.getDefault().createSocket(hostname, port);
        } catch (IOException ioe) {
            throw new ChannelOpenException(ChannelOpenException.CONNECT_FAILED, ioe.getMessage());
        }
        return null;
  }

}
TOP

Related Classes of com.adito.tunnels.agent.LocalForwardingChannel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.