public Socks5Message(int cmd,String hostName,int port){
  super(cmd,null,port);
  this.host=hostName;
  this.version=SOCKS_VERSION;
  addrType=SOCKS_ATYP_DOMAINNAME;
  byte addr[]=hostName.getBytes();
  data=new byte[7 + addr.length];
  data[0]=(byte)SOCKS_VERSION;
  data[1]=(byte)command;
  data[2]=(byte)0;
  data[3]=(byte)SOCKS_ATYP_DOMAINNAME;
  data[4]=(byte)addr.length;
  System.arraycopy(addr,0,data,5,addr.length);
  data[data.length - 2]=(byte)(port >> 8);
  data[data.length - 1]=(byte)(port);
}

public Socks5Message ( int cmd , String hostName , int port ) { super ( cmd , null , port ) ; this . host = hostName ; this . version = SOCKS_VERSION ; addrType = SOCKS_ATYP_DOMAINNAME ; byte addr [ ] = hostName . getBytes ( ) ; data = new byte [ 7 + addr . length ] ; data [ 0 ] = ( byte ) SOCKS_VERSION ; data [ 1 ] = ( byte ) command ; data [ 2 ] = ( byte ) 0 ; data [ 3 ] = ( byte ) SOCKS_ATYP_DOMAINNAME ; data [ 4 ] = ( byte ) addr . length ; System . arraycopy ( addr , 0 , data , 5 , addr . length ) ; data [ data . length - 2 ] = ( byte ) ( port > > 8 ) ; data [ data . length - 1 ] = ( byte ) ( port ) ; }
construct client request or server response .
