|
Register | FAQ | The Twelve Commandments | Members List | Calendar | Arcade | Find the Best VPN | Today's Posts | Search |
General Gnutella Development Discussion For general discussion about Gnutella development. |
| LinkBack | Thread Tools | Display Modes |
| |||
sizeof() returns the total storage bytes of the struct including padded bytes for alignment. It is returning 24 because of a byte that was added for alignment. The format of your structure looks fine except payloadID, TTL, Hops, and payloadlen should probably be unsigned. Last edited by tshdos; April 24th, 2002 at 05:21 PM. |
| |||
You shouldn't have to copy it to a string in order to send it, just pass a pointer to the struct. Only copy/send 23 bytes either way you do it. If you really need to copy it to a string just use memcpy. |
| |||
Yes, I copy it with memcpy, but I must specify the size. And, if sizeof says 24bytes, I should copy 24bytes, however I need 23 bytes. Thats my problem. You say I must send a pointer to struct, mmm, if I send a pointer to data on my computer to another PC, I think it will not work. Thanks for answer. |
| |||
Quote:
Quote:
i.e.: bytes = send( sock, (char*)&struct, 23, 0 ) |
| |||
Failed. I was searching information about this. I found something. A struct can have a diferent size than its elements. it´s happens because there is a byte used to struct. Then I can´t use this solution. I need to copy element by element. If someone has some code to do this, please, tell me. I´m working on that. |
| |||
create a small char buffer, memcpy into it and send the buffer. Monitor your serial port and watch to see if the bytes are correct. Look at other client source code and see how they did it and quit re-inventing the wheel. Even better, use another clients source code and build on top of that so we can get more features instead of more base code that we don't need. |
| |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Zip Header | Geoff114 | General Mac Support | 1 | November 30th, 2005 09:18 AM |
zip header | Unregistered | Download/Upload Problems | 2 | June 25th, 2002 08:22 AM |
Creating header struct | Unregistered | General Gnutella Development Discussion | 3 | April 4th, 2002 09:50 AM |
help! zip header?? | Unregistered | Mac OSX | 3 | March 28th, 2002 07:10 PM |
zip header | Unregistered | Mac OSX | 2 | March 18th, 2002 06:53 PM |