Gnutella Forums  

Go Back   Gnutella Forums > Gnutella News and Gnutelliums Forums > General Gnutella Development Discussion
Register FAQ The Twelve Commandments Members List Calendar Arcade Find the Best VPN Today's Posts

General Gnutella Development Discussion For general discussion about Gnutella development.


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old May 22nd, 2002
Apprentice
 
Join Date: May 22nd, 2002
Posts: 8
nicokras is flying high
Question Receiving Pong from Gnut

I'm developing a Linux Gnutella client for studing purposes. The thing is that I'm trying to prove my version with Gnut, and I don't receive what I expected when Sent my ping.
I send the "GNUTELLA CONNECT...." and Gnut replies my with the "Gnutella OK", so I write into the port the ping with a certaing ID.
I debugged the Gnut code, and I saw that It receives my Ping well, and proccess it ok, and sends to me back, with the same ID i gave it.
The problem is, that I receive anything but what I'm expected to receive.

Thanks.

This is the part of the code where I receive the Pong Structure.
Note: pszBuffer is declared as Global Variable, and is an unsigned *char.

Structure:

struct stHeader
{
unsigned char szID[16];
unsigned char cPayload; // 1 byte
unsigned char cTTL;
unsigned char cHops;
unsigned char lPayLength[4]; // 4 bytes
};

struct stPong
{
unsigned char iPort[2]; // 2 bytes
unsigned char szIP[4];
unsigned char lCantArch[4];
unsigned char lCantKb[4];
};


/************************************************** ****************************/
int fRecibirPong(int iSock)
{
HEADER *stHead;
PAQUETE *pstPaquete;
PONG *stPong;
unsigned long int lTam;

if ((stHead = (HEADER*)malloc(sizeof(HEADER))) == NULL)
{
fMsgError("MEMORIA INSUFICIENTE");
fFin();
}

// printf("Tamaño de stHead: %d\n", sizeof(HEADER));

memset(pszBuffer,0,MAXBUFCONECT);

if (recv(iSock, pszBuffer, sizeof(HEADER),0) < 0)
{
fMsgError("ERROR AL RECIBIR UN PONG");
fFin();
}

stHead = (HEADER *)pszBuffer;

fImprimirHeader(stHead);

lTam = *((int *)stHead->lPayLength);
printf("Tamaño de stPong: %ld\n", lTam);
if ((stPong = (PONG*)malloc(sizeof(PONG))) == NULL)
{
fMsgError("MEMORIA INSUFICIENTE");
fFin();
}

memset(pszBuffer,0,MAXBUFCONECT);

if (recv(iSock, pszBuffer, sizeof(PONG),0) < 0)
{
fMsgError("ERROR AL RECIBIR UN PONG");
fFin();
}
stPong = (PONG*)pszBuffer;

fGuardarLog("PONG RECIBIDO");
fImprimirPong(stPong);
return 1;
}
Reply With Quote
  #2 (permalink)  
Old May 22nd, 2002
Gnutella Veteran
 
Join Date: March 24th, 2002
Location: Virginia
Posts: 101
tshdos is flying high
Default

what is the value this line prints

// printf("Tamaño de stHead: %d\n", sizeof(HEADER));
Reply With Quote
  #3 (permalink)  
Old May 23rd, 2002
Apprentice
 
Join Date: May 22nd, 2002
Posts: 8
nicokras is flying high
Default

This line is under comments, and it was simply wrote to know if Header size was well. It doesn't do anything.
Reply With Quote
  #4 (permalink)  
Old May 23rd, 2002
Gnutella Veteran
 
Join Date: March 24th, 2002
Location: Virginia
Posts: 101
tshdos is flying high
Default

I know it is commented out. What does it say the sizeof(HEADER) equals?
Reply With Quote
  #5 (permalink)  
Old May 23rd, 2002
Apprentice
 
Join Date: May 22nd, 2002
Posts: 8
nicokras is flying high
Default

HEADER is the type defined for the stHeader Struct:

typedef struct stHeader HEADER;
Reply With Quote
  #6 (permalink)  
Old May 23rd, 2002
Gnutella Veteran
 
Join Date: March 24th, 2002
Location: Virginia
Posts: 101
tshdos is flying high
Default

I understand that. Let me try to be a little clearer. When you call sizeof(HEADER) does it return 23 or 24? I ask because on win32 if you call it, it returns 24 which is incorrect.
Reply With Quote
  #7 (permalink)  
Old May 23rd, 2002
Apprentice
 
Join Date: May 22nd, 2002
Posts: 8
nicokras is flying high
Default

It returns me 23. I had problems when defined the PayLength as long Int, so I changed it to unsigned char, and sizeof(HEADER) return me 23 now.
Reply With Quote
  #8 (permalink)  
Old May 23rd, 2002
Gnutella Veteran
 
Join Date: March 24th, 2002
Location: Virginia
Posts: 101
tshdos is flying high
Default

Can you post the bytes that you receive here?
Reply With Quote
  #9 (permalink)  
Old May 23rd, 2002
Apprentice
 
Join Date: May 22nd, 2002
Posts: 8
nicokras is flying high
Default

I don't undestand what you want, but if you need the bytes I receive when I was supposed to receive my ID, I need I to tell you that it depends on the ocassion. It changes all the time. But always seems like it takes my ID ( which is formed by numbers, but they are characters )...an changes it to char. It's like doind char(number), where number is a part of my ID...

I think I'm not doing something I have to do to receive this, so I get my ID like anything else.

The only thing I can give you now, is the whole code. Do yo need it ???
Reply With Quote
  #10 (permalink)  
Old May 23rd, 2002
Gnutella Veteran
 
Join Date: March 24th, 2002
Location: Virginia
Posts: 101
tshdos is flying high
Default

Can you just paste the bytes for your request and a reply here?
ie:

Request:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 00 05 00 00 00 00 00

Reply:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 01 01 00 00 00 00 0E 18 CA 7F 00 00 01 00 00 00 00 00 00 00 00
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not Receiving Pro/ Received Unknown Bill pierd001 Windows 5 December 27th, 2006 06:31 AM
Receiving Key Error Message when Running Install Exe SharonB Windows 0 August 24th, 2005 05:46 AM
receiving constant error Unregistered XoloX Beta program 6 November 22nd, 2002 11:42 AM
Not receiving any hosts when I start napshare duxbuz NapShare (Cross-platform) 2 June 16th, 2002 11:03 AM
Receiving Problems umStefa Gnucleus (Windows) 1 April 26th, 2002 05:27 PM


All times are GMT -7. The time now is 06:29 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 ©2011, Crawlability, Inc.

Copyright © 2020 Gnutella Forums.
All Rights Reserved.