Code example for SocketChannel

Methods: finishConnect, isConnectionPending, register

0
		int port = uri.getPort();
		return port == -1 ? WebSocket.DEFAULT_PORT : port;
	} 
 
	private void finishConnect() throws IOException { 
		if (client.isConnectionPending()) {
			client.finishConnect();
		} 
 
		// Now that we're connected, re-register for only 'READ' keys. 
		client.register(selector, SelectionKey.OP_READ);
 
		sendHandshake(); 
	} 
 
	private void sendHandshake() throws IOException { 
		String path = uri.getPath();
		if (path.indexOf("/") != 0) {
			path = "/" + path;
		} 
		int port = getPort();