if(client_sock != null) try {client_sock.close();} catch(IOException e) {}
   public void run() {       Socket     client_sock;       Connection conn=null;       Address    peer_addr;       while(srv_sock != null) {           try {               client_sock=srv_sock.accept();               if(log.isTraceEnabled())                   log.trace("accepted connection from " + client_sock.getInetAddress() + ":" + client_sock.getPort());               try {                   client_sock.setSendBufferSize(send_buf_size);               }               catch(IllegalArgumentException ex) {                   if(log.isErrorEnabled()) log.error("exception setting send buffer size to " +                          send_buf_size + " bytes", ex);               }               try {                   client_sock.setReceiveBufferSize(recv_buf_size);               }               catch(IllegalArgumentException ex) {                   if(log.isErrorEnabled()) log.error("exception setting receive buffer size to " +                          send_buf_size + " bytes", ex);               }               client_sock.setKeepAlive(true);               // create new thread and add to conn table               conn=new Connection(client_sock, null); // will call receive(msg)               // get peer's address               peer_addr=conn.readPeerAddress(client_sock);               // client_addr=new IpAddress(client_sock.getInetAddress(), client_port);               conn.setPeerAddress(peer_addr);               synchronized(conns) {                   if(conns.containsKey(peer_addr)) {                       if(log.isTraceEnabled())                           log.trace(peer_addr + " is already there, will reuse connection");                       //conn.destroy();                       //continue; // return; // we cannot terminate the thread (bela Sept 2 2004)                   }                   else {                       // conns.put(peer_addr, conn);                       addConnection(peer_addr, conn);                       notifyConnectionOpened(peer_addr);                   }               }               conn.init(); // starts handler thread on this socket           }           catch(SocketException sock_ex) {               if(log.isInfoEnabled()) log.info("exception is " + sock_ex);               if(conn != null)                   conn.destroy();               if(srv_sock == null)                   break;  // socket was closed, therefore stop           }           catch(Throwable ex) {               if(log.isWarnEnabled()) log.warn("exception is " + ex);               if(srv_sock == null)                   break;  // socket was closed, therefore stop           }       }       if(log.isTraceEnabled())           log.trace(Thread.currentThread().getName() + " terminated");   }