List of usage examples for java.nio.channels AsynchronousServerSocketChannel bind
public final AsynchronousServerSocketChannel bind(SocketAddress local) throws IOException
From source file:Main.java
public static void main(String[] args) throws Exception { AsynchronousServerSocketChannel server = AsynchronousServerSocketChannel.open(); String host = "localhost"; int port = 8989; InetSocketAddress sAddr = new InetSocketAddress(host, port); server.bind(sAddr); System.out.format("Server is listening at %s%n", sAddr); Attachment attach = new Attachment(); attach.server = server;/* w w w . j av a 2 s .c o m*/ server.accept(attach, new ConnectionHandler()); Thread.currentThread().join(); }