Code example for ServerSocketChannel

Methods: accept

0
	 
	@Override 
	public void run() { 
		try { 
			ServerSocketChannel serverSocketChannel = (ServerSocketChannel) key.channel();
			SocketChannel socketChannel = serverSocketChannel.accept();
			socketChannel.configureBlocking(false);
			 
			HandlerAdapter attachment = new HandlerAdapter(7, (ClientHandler) key.attachment());
			SelectionKey registeredkey = dispatcher.register(socketChannel, SelectionKey.OP_READ, attachment);
			attachment.setKey(registeredkey);
			 
			System.out.println("Got connection from["+socketChannel+"]");
 
		} catch (IOException e) {
			Thread.currentThread().interrupt();
		}finally{ 
		} 
	} 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE