Creating a Non-Blocking Server Socket : NIO Socket « Network Protocol « Java
- Java
- Network Protocol
- NIO Socket
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));
}
}
Related examples in the same category