code: public void write(OutputStream out)throws SocksException,
                                               IOException{
       if(data == null){
         Socks5Message msg;
  
         if(addrType == SOCKS_ATYP_DOMAINNAME)
            msg = new Socks5Message(command,host,port);
         else{
            if(ip == null){
               try{
                 ip = InetAddress.getByName(host);
               }catch(UnknownHostException uh_ex){
                 throw new SocksException(Proxy.SOCKS_JUST_ERROR);
               }
            }
            msg = new Socks5Message(command,ip,port);
         }
         data = msg.data;
       }
       out.write(data);
     }
docs: Writes the message to the stream.
  @param out Output stream to which message should be written.