Well, it depends how exactly your "putting your data in a struct" but you probably will have random data (perhaps 0s, depending on the OS and/or malloc, and previous allocations...).

Generally you'll want to have a header for each packet (datagram) with the packet id and data length, and optionally but preferably a checksum to make sure your file is intact when all is said and done...

While it's true that the max for a datagram is technically 64K, that does imply fragmentation (at best) or the datagram being dropped (if the router doesn't want to frag...) or more chances of loosing a packet fragment in route...

You might want to check the code of a TFTP implementation to see all everything's done (and perhaps copy your whole implementation from a BSD licensed source if you feel like it!)


Ammo