Problems sending MSGs(ping, pong, query...) over gnutella network I'm developing an open source gnutella servent in Visual Basic, i've followed the protocol specifications yet when i send a pong to a server it disconnects my socket connection or an error (in the socket) is triggered. Also, when i connect to a main servent (like gnutella.hostscache.com) they send me lot's of msgs of uknown type, like 24 (one of the most common), some of these msgs have a huge payload length (like 1401), what's that stuff?. Could someone help me?
The following is my code for sending a Ping and a Pong:
Function Ping(Optional guid As String) As String
'Utils: Sends a Ping Message
'
'-------
If guid = "" Then guid = cx(GetGUID)
'-------
Ping = guid & Chr(0) & Chr(5) & String(5, Chr(0))
End Function
Function Pong(Optional Address As String, Optional Port As Integer, Optional guid As String, Optional FileSpace As Double, Optional FileNum As Double, Optional TTL As Byte, Optional Hop As Byte) As String
Dim Body As String
'-------
If Address = "" Then Address = MyAddress
If Port = 0 Then Port = MyPort
If guid = "" Then guid = cx(GetGUID)
If FileSpace = 0 Then FileSpace = MySize
If FileNum = 0 Then FileNum = MyFiles
If TTL = 0 Then TTL = 5
'-------
Body = IncStr(EncNumber(CDbl(Port)), 2) & EncAddress(MyAddress) & IncStr(EncNumber(FileNum), 4) & IncStr(EncNumber(FileSpace), 4)
Pong = guid & Chr(1) & Chr(TTL) & Chr(Hop) & IncStr(EncNumber(Len(Body)), 4) & Body
End Function |