Bittorrent - Peers (Big Endian Network Notation)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kyndig
    New Member
    • Apr 2010
    • 3

    Bittorrent - Peers (Big Endian Network Notation)

    Hey,

    I have been working on a client in C#, however ive hit a road block, when the tracker sends its request it can be in two formats, one is a BEncoded dictionary which is fine.

    The other is a string:

    "the peers value may be a string consisting of multiples of 6 bytes. First 4 bytes are the IP address and last 2 bytes are the port number. All in network (big endian) notation"

    However ive tried in vain and still cant get this to give me the right values, I know this because the port number in the last 2 bytes or several occasions is coming out as 6 digits.

    Thanks in advance.

    Code:
    byte[] byteArray = Encoding.Unicode.GetBytes(srespone.Value.ToString());
    byte[] beUnicodeBytes = Encoding.Convert(Encoding.Unicode, Encoding.BigEndianUnicode, byteArray);
Working...