Code example for ServerSocketChannel

Methods: registersocketconfigureBlocking

0
	} 
 
 
	public void start(int port) throws IOException {
		serverSocketChannel = ServerSocketChannel.open();
		serverSocketChannel.configureBlocking(false);
		serverSocketChannel.socket().bind(new InetSocketAddress(port));
		selector = Selector.open();
		serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT);
	} 
 
	public void stop() throws IOException { 
		serverSocketChannel.close();
	} 
 
 
	public void processIncoming() throws IOException, ClassNotFoundException{ 
		selector.selectNow();
		for (SelectionKey selectionKey : selector.selectedKeys()) {
			if (selectionKey.isReadable()) {
Contextual code suggestions in your IDE  Get Codota for Java