public Thread connect() throws IOException {
  this.running=true;
  this.readyState=WEBSOCKET_STATE_CONNECTING;
  socketChannel=SocketChannel.open();
  socketChannel.configureBlocking(false);
  socketChannel.connect(new InetSocketAddress(uri.getHost(),port));
  System.setProperty("java.net.preferIPv4Stack","true");
  System.setProperty("java.net.preferIPv6Addresses","false");
  selector=Selector.open();
  socketChannel.register(selector,SelectionKey.OP_CONNECT);
  Log.v("websocket","Starting a new thread to manage data reading/writing");
  Thread th=new Thread(this);
  th.start();
  return th;
}

public Thread connect ( ) throws IOException { this . running = true ; this . readyState = WEBSOCKET_STATE_CONNECTING ; socketChannel = SocketChannel . open ( ) ; socketChannel . configureBlocking ( false ) ; socketChannel . connect ( new InetSocketAddress ( uri . getHost ( ) , port ) ) ; System . setProperty ( "java.net.preferIPv4Stack" , "true" ) ; System . setProperty ( "java.net.preferIPv6Addresses" , "false" ) ; selector = Selector . open ( ) ; socketChannel . register ( selector , SelectionKey . OP_CONNECT ) ; Log . v ( "websocket" , "Starting a new thread to manage data reading/writing" ) ; Thread th = new Thread ( this ) ; th . start ( ) ; return th ; }
starts a new thread and connects to server
