Mega Code Archive

 
Categories / Java / Network Protocol
 

Creating a Non-Blocking Server Socket

import java.net.InetSocketAddress; import java.nio.channels.ServerSocketChannel; public class Main {   public static void main(String[] argv) throws Exception {     ServerSocketChannel ssChannel = ServerSocketChannel.open();     ssChannel.configureBlocking(false);     int port = 80;     ssChannel.socket().bind(new InetSocketAddress(port));   } }