List of usage examples for java.nio.channels AsynchronousServerSocketChannel accept
public abstract <A> void accept(A attachment, CompletionHandler<AsynchronousSocketChannel, ? super A> handler);
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);//from www. java 2 s .c o m System.out.format("Server is listening at %s%n", sAddr); Attachment attach = new Attachment(); attach.server = server; server.accept(attach, new ConnectionHandler()); Thread.currentThread().join(); }