I am also working with the protocol and trying to write my own client, but mine will be in Perl. I ran into a problem that sounded similar to yours.
I would send:
GNUTELLA CONNECT/0.6\r\n
\r\n
They would send:
GNUTELLA/0.6 200 (...)
And from what I was reading on all the documentation I could find about the protcol, it said that you should now be connected and able to send/receive ping/pong/query/queryhits.
But when I attempted to do any of this and read from the socket for my response, I would find (like you said) useful (text) information about my server. I would then eventually be disconnected from the server in less than a minute.
What I found out from (after hours of searching) an alternative document, that the handshake actually goes like:
client:
GNUTELLA CONNECT/0.6\r\n
\r\n
server:
GNUTELLA/0.6 200 (...)\r\n
(optional server specifics)\r\n
\r\n
client:
GNUTELLA/0.6 200\r\n
\r\n
And now, at this point you are offically connected, and we remain so indefinatly. And from what the documents say, you should now be able to send and receive ping/pong/query/queryhits.
I am not actually trying to work with sending a query at the moment, instead I am trying to understand how to send a ping.
This is where I become lost again. The protocol documentation that I have found is ver unclear about the specifics for sending communications at this point.
I hope the information I have shared will atleast help you get properly connected to the network. But as for the problem of sending a query, (or ping in my case) I do not know what to tell you.
Best of luck,
Jason |