public TCPChannelClient(ExecutorService executor,TCPChannelEvents eventListener,String ip,int port){
  this.executor=executor;
  executorThreadCheck=new ThreadUtils.ThreadChecker();
  executorThreadCheck.detachThread();
  this.eventListener=eventListener;
  InetAddress address;
  try {
    address=InetAddress.getByName(ip);
  }
 catch (  UnknownHostException e) {
    reportError("Invalid IP address.");
    return;
  }
  if (address.isAnyLocalAddress()) {
    socket=new TCPSocketServer(address,port);
  }
 else {
    socket=new TCPSocketClient(address,port);
  }
  socket.start();
}

public TCPChannelClient ( ExecutorService executor , TCPChannelEvents eventListener , String ip , int port ) { this . executor = executor ; executorThreadCheck = new ThreadUtils . ThreadChecker ( ) ; executorThreadCheck . detachThread ( ) ; this . eventListener = eventListener ; InetAddress address ; try { address = InetAddress . getByName ( ip ) ; } catch ( UnknownHostException e ) { reportError ( "Invalid IP address." ) ; return ; } if ( address . isAnyLocalAddress ( ) ) { socket = new TCPSocketServer ( address , port ) ; } else { socket = new TCPSocketClient ( address , port ) ; } socket . start ( ) ; }
initializes the tcpchannelclient . if ip is a local ip address , starts a listening server on that ip . if not , instead connects to the ip .
