コード例 #1
0
ファイル: ServerWorker.java プロジェクト: qza/gft-crw
 public void shutdown() {
   try {
     socket.close();
     workers.remove(this);
   } catch (Exception e) {
     log.warn("Can't close worker ::: " + e.getMessage());
   }
 }
コード例 #2
0
ファイル: SocketQueue.java プロジェクト: berylyl/HttpServer
 /**
  * close socket,remove socket from array
  *
  * @param socket
  */
 public static void closeConnection(AsynchronousSocketChannel socket) {
   try {
     logger.info("close client socket:" + socket.getRemoteAddress().toString());
     socket.close();
   } catch (IOException e) {
     logger.error("socket close error", e);
   }
   removeClientConnection(socket);
 }
コード例 #3
0
 @Override
 public void failed(Throwable exc, AsyncTimeClientHandler attachment) {
   exc.printStackTrace();
   try {
     client.close();
     latch.countDown();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
コード例 #4
0
ファイル: SocketQueue.java プロジェクト: berylyl/HttpServer
  /** 关闭全部Socket */
  public static void closeAllConnections() {
    Enumeration<AsynchronousSocketChannel> it = allClientSocket.keys();
    while (it.hasMoreElements()) {
      AsynchronousSocketChannel so = it.nextElement();

      try {
        logger.info("close client socket:" + so.getRemoteAddress().toString());
        so.close();
      } catch (IOException e) {
        logger.error("SocketQueue.closeAllSocket IOException:", e);
      }
    }
    allClientSocket.clear();
  }
コード例 #5
0
 @Override
 public void run() {
   latch = new CountDownLatch(1);
   client.connect(new InetSocketAddress(host, port), this, this);
   try {
     latch.await();
   } catch (InterruptedException e1) {
     e1.printStackTrace();
   }
   try {
     client.close();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
コード例 #6
0
 public void dispose() {
   if (!isDispose) {
     isDispose = true;
   }
   if (player != null) {
     if (player.getCurrentHall() != null) {
       player.getCurrentHall().kickPlayer(this);
     }
     player = null;
   }
   if (readBuffer != null) {
     BufferPool.getInstance().releaseBuffer(readBuffer);
     readBuffer = null;
   }
   if (channel != null) {
     try {
       channel.close();
     } catch (IOException e) {
       e.printStackTrace();
     } finally {
       channel = null;
     }
   }
 }