code: public Socket accept() throws IOException{
        Socket s;
  
        if(!doing_direct){
           if(proxy == null) return null;
  
           ProxyMessage msg = proxy.accept();
           s = msg.ip == null? new SocksSocket(msg.host,msg.port,proxy)
                                    : new SocksSocket(msg.ip,msg.port,proxy);
           //Set timeout back to 0
           proxy.proxySocket.setSoTimeout(0);
        }else{ //Direct Connection
  
            //Mimic the proxy behaviour,
            //only accept connections from the speciefed host.
            while(true){
              s = super.accept();
              if(s.getInetAddress().equals(remoteAddr)){
                 //got the connection from the right host
                 //Close listenning socket.
                 break;
              }else
                 s.close(); //Drop all connections from other hosts
            }
  
        }
        proxy = null;
        //Return accepted socket
        return s;
     }
docs: Accepts the incoming connection.