예제 #1
0
 public Server(InetSocketAddress bindAddress, Acceptor acceptor) throws IOException {
   this.bindAddress = bindAddress;
   if (acceptor.getState() != Thread.State.RUNNABLE) {
     acceptor.start();
   }
   this.acceptor = acceptor;
   serverSocketChannel =
       (ServerSocketChannel)
           ServerSocketChannel.open().bind(this.bindAddress).configureBlocking(false);
   acceptor.register(serverSocketChannel);
   logger.info("start server bind in : {}", bindAddress);
 }
예제 #2
0
 public void close() {
   try {
     serverSocketChannel.close();
     acceptor.close();
   } catch (Exception e) {
     logger.error(e.getMessage(), e);
   }
 }