예제 #1
0
  public void start() {
    if (receiver != null) receiver.stop();
    receiver = new Receiver(server.factory).start();

    if (isSenderUsed()) {
      if (sender != null) sender.stop();
      sender = new Sender(server.factory, server.sendQueueSize()).start();
    }
  }
예제 #2
0
 public void close() throws IOException {
   // can close even if start was never called...
   send_lock.lock();
   try {
     connectionPeerReceiver.stop();
     if (isSenderUsed()) {
       sender.stop();
     }
     Util.close(sock);
     Util.close(out);
     Util.close(in);
   } finally {
     send_lock.unlock();
   }
   mapper.notifyConnectionClosed(peer_addr);
 }
예제 #3
0
 public void close() throws IOException {
   send_lock.lock();
   try {
     Util.close(out, in, sock);
     if (receiver != null) {
       receiver.stop();
       receiver = null;
     }
     if (sender != null) {
       sender.stop();
       sender = null;
     }
   } finally {
     send_lock.unlock();
   }
 }