View Single Post
  #1 (permalink)  
Old December 13th, 2003
Tw|st3r Tw|st3r is offline
Join Date: December 13th, 2003
Location: Italy
Posts: 1
Tw|st3r is flying high
Default Writing Java client.. how should I implement query/query hits?

I am trying to write my GNUTella client using Java.

I wrote the code to find the first node on the network, then sent to it the "CONNECT GNUTELLA/0.6" message.

The servent correctly says "200 OK", and then.. how can I perform a search query?

At this point I got:
* the IP and port of the servent I am connected to
* its input and output streams.

The RFC says
The message header is 23 bytes divided into the following fields.

Bytes: Description:
0-15 Message ID/GUID (Globally Unique ID)
16 Payload Type
17 TTL (Time To Live)
18 Hops
19-22 Payload Length
A Query message has the following fields:

Bytes: Description:
0-1 Minimum Speed. The minimum speed (in kb/second) of servents
that should respond to this message. A servent receiving a
Query message with a Minimum Speed field of n kb/s SHOULD
only respond with a Query Hit if it is able to communicate at
a speed >= n kb/s.

2- Search Criteria. This field is terminated by a NUL (0x00). [...]
The Search Criteria is text, and it has never been specified which
charset that text was encoded with. Therefore, servents MUST assume
it is pure ASCII only.
so I built byte by byte the message giving a search criteria like "madonna" or stgh like that.

Finally I printed the bytes array to the output stream connected with the servent, but:

* if I read the servent reply on the input stream I got unuseful information about the servent.. nothing like the query hits

* if I create a ServerSocket bound to port 6346, this socket hungs on listening an never recieves anything

So.. what shall I do to get the query hits?

Thanks in advance
Reply With Quote