View Single Post
  #1 (permalink)  
Old August 31st, 2006
beat beat is offline
Novicius
 
Join Date: August 31st, 2006
Posts: 2
beat is flying high
Default Message Problems

hi. i´m interessted in the Gnutella Protocol and i´m doing my first steps with programming it. But i have a problem. when the handshake connection is established (it works cause i get a GNUTTELLA CONNECT OK... from der server servent) i´m trying to send a ping, hoping to receive a pong. But nothing happens. I cannot find errors in my code. Sb please help me.

Code:
import java.io.*;
import java.net.*;

public class Test {
	public static void main (String[] args) throws IOException{

		byte[] ping = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x10,0x11,0x13,
					   0x14,0x0A,0x0B,0x0C,0x0D,0x0E,0x00,0x00000000};

		Socket s = new Socket("67.188.93.23",6346); //"201.37.69.72",12937
		PrintStream os = new PrintStream(s.getOutputStream());
		//String connect = "GET /get//walkon.mp3 HTTP/1.1\r\nUser-Agent: Gnutella\r\nHost: 127.0.0.1:14236\r\nConnection: Keep-Alive\r\nRange: bytes=0-\r\n\n";
		String connect = "GNUTELLA CONNECT/0.6\n\n";
		os.print(connect);
		BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
		os.print("GNUTELLA CONNECT/0.6 200 OK\n\n");

		for(int i = 0; i<ping.length;i++) {
			os.print(ping[i]);
		}

		System.out.println(in.readLine());



	}
}
Can i Ping a Gnutella host without handshaking before??

thx beat,austria
Reply With Quote