Quote:
Originally posted by Ahri I got v0.4 protocal specs. |
Very helpful!
Quote:
I figured out the answer to my question this morning. What happens is VB automatically takes the binary info. and converts it to ASCII text. I wanted to know how to convert it back into its original form. |
VB can store the relsults of Winsock.GetData in
either a BSTR or an array of integers
A BSTR is a "Basic String", preceeded by it's length (four bytes) which occupies
two bytes per character on Unicode supporting systems (VB supports Unicode for purposes of interacting with ActiveX controls), so even though you
think there's only one byte per character in the string, that's not the way it's stored in RAM.
Manipulating the data might be easier if you GetData it into an array of integers and interpret it seperately. VB programmers are disadvantaged by the loss of a "typecast" operator, which would allow me to take my array Incoming() As Integer and "reinterpret" its contents as though it were a Type DescriptorHeader... You must parse the elements of the array by hand, but at least it'll be easier than parsing the BSTR (as Gnutella's doesn't use ASCII descriptors like OpenNap).
Also, there's nothing saying you can't
retrieve you data into one variable (say a String) and SendData an array of integers! Use whatever's least painful for you
Quote:
Also, the lengths in bytes of the incomming data does not always equal 23 + the payload length. The extra data is almost always less than 23 bytes. What's going on? |
It is possible for descriptors to span TCP packets; that is, you may have to GetData again to retrieve the rest of the descriptor...
What lengths
are you getting for your payloads?
Pings should always be 0, Pongs always 14, and Pushes always 26... There are NO pads between descriptors in the Gnutella data
stream, so you will have to keep careful track of where one descriptor ends and the next begins. If you lose your place, it's curtains; you will be disconnected.