private void writeRequest(final NextFilter nextFilter,final SocksProxyRequest request,int step){
  try {
    IoBuffer buf=null;
    if (step == SocksProxyConstants.SOCKS5_GREETING_STEP) {
      buf=encodeInitialGreetingPacket(request);
    }
 else     if (step == SocksProxyConstants.SOCKS5_AUTH_STEP) {
      buf=encodeAuthenticationPacket(request);
      if (buf == null) {
        step=SocksProxyConstants.SOCKS5_REQUEST_STEP;
      }
    }
    if (step == SocksProxyConstants.SOCKS5_REQUEST_STEP) {
      buf=encodeProxyRequestPacket(request);
    }
    buf.flip();
    writeData(nextFilter,buf);
  }
 catch (  Exception ex) {
    closeSession("Unable to send Socks request: ",ex);
  }
}

private void writeRequest ( final NextFilter nextFilter , final SocksProxyRequest request , int step ) { try { IoBuffer buf = null ; if ( step == SocksProxyConstants . SOCKS5_GREETING_STEP ) { buf = encodeInitialGreetingPacket ( request ) ; } else if ( step == SocksProxyConstants . SOCKS5_AUTH_STEP ) { buf = encodeAuthenticationPacket ( request ) ; if ( buf == null ) { step = SocksProxyConstants . SOCKS5_REQUEST_STEP ; } } if ( step == SocksProxyConstants . SOCKS5_REQUEST_STEP ) { buf = encodeProxyRequestPacket ( request ) ; } buf . flip ( ) ; writeData ( nextFilter , buf ) ; } catch ( Exception ex ) { closeSession ( "Unable to send Socks request: " , ex ) ; } }
encodes a socks5 request and writes it to the next filter so it can be sent to the proxy server .
