[bittorrent] compact ip problem
ghost.ued at gmail.com
Wed Aug 22 22:08:21 EDT 2007
"You want to save each section of the
IP address as a unsigned 8 bit integer. "
actually, in a 32 bit integer xD
Dazen, the operator you need is not >>. It's >>> .
Look for java bitwise operators, and you will see the difference.
i did not understand your code, but the size seems right: each pair Ip
and port uses 6 bytes.
here is my code:
byte ipembytes =InetAddress.getByName(ip);
peerByteResponse[ actualLength] = ipembytes;
peerByteResponse[ actualLength+1] = ipembytes ;
peerByteResponse[ actualLength+2] = ipembytes ;
peerByteResponse[ actualLength+3] = ipembytes ;
peerByteResponse[actualLength+4]= (byte)(port >>>8);
(peerByteResponse is a bytre array with the peers string)
More information about the BitTorrent