Creating a Non-Blocking Server Socket : NIO Socket « Network Protocol « Java






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

1.Non block server
2.Finger Server
3.Reading from a SocketChannel
4.Writing to a SocketChannel
5.Creating a Non-Blocking Socket: requires a socket channel.
6.Accepting a Connection on a ServerSocketChannel
7.Using a Selector to Manage Non-Blocking Server Sockets