Gnutella Forums

Gnutella Forums (https://www.gnutellaforums.com/)
-   General Gnutella Development Discussion (https://www.gnutellaforums.com/general-gnutella-development-discussion/)
-   -   Header struct (https://www.gnutellaforums.com/general-gnutella-development-discussion/10775-header-struct.html)

tshdos April 30th, 2002 04:43 PM

Cerebro:

If you could post the code you are having problems with we can tell you how to fix it.

Here is an example though:

struct GHEADER
{
unsigned char MsgID[16];
unsigned char FuncID;
unsigned char TTL;
unsigned char Hops;
unsigned long PayloadLen;
};

// Assume hdr is a GHEADER struct that has been filled

// Method 1
// copy from struct to buffer
char buffer[23];
memcpy( buffer, (char*)&hdr, 23 );

// Method 2
// copy struct member by member to buffer
char buffer2[23];
memcpy( &buffer[0], hdr.MsgID, 16 );
memcpy( &buffer[16], hdr.FuncID, 1 );
memcpy( &buffer[17], hdr.TTL, 1 );
memcpy( &buffer[18], hdr.Hops, 1 );
memcpy( &buffer[19], hdr.PayloadLen, 4 );

Cerebro May 2nd, 2002 05:11 AM

Thanks, but I think payload length must be int, because it must to be 4 bytes long.

tshdos May 2nd, 2002 06:13 AM

On Win32 unsigned int and unsigned long are the same (4 bytes).


All times are GMT -7. The time now is 02:36 AM.

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

Copyright © 2020 Gnutella Forums.
All Rights Reserved.