maximum packet size? (winsock and udp)

Started by
2 comments, last by MrShmoo 20 years, 10 months ago
I''ve made quite a bit of progress on my networked first person shooter game, and I''m able to handle multiple clients easily. But my question is: is there a maximum packet size? Up to 3 clients can connect and move around adequately, but when the 4th client connects everything crashes. I print out the size that recvfrom is setting and it is 121...which doesn''t seem too big to me (the way things work is that the server distributes one packet to all the clients, so the more clients that connect the bigger the packet will be). If I have hit my limit, what are possible solutions to the problem? Thanks!
Advertisement
The actual maximum UDP packet size tends to be about 32k. In practice you don''t normally want to send any more than about 1400 bytes in a packet. 121 bytes certainly isn''t too large, if your program is crashing, there is likely a problem elsewhere in your code.

It''s unlikely you''ll ever want to send more data than this to a single client in each packet you send - if you do, in an internet game, chances are player connections won''t be able to handle the amount of data anyway, and will become horribly lagged. If you have a reason to send this much data however (like you''re playing a huge LAN game or something), simply divide it into multiple packets before sending it. There''s no reason you can only send one packet to each client per frame or whatever, send as many as you need (provided the rest of your networking system can handle it)
Thanks for your answer...I figured that there wouldn''t be such a small limit imposed on packet size. So to go about fixing my error I went in and changed all the char[]''s i was sending from char[128]''s to char[256]''s. I also changed it so the server (currently single threaded) waits longer to receive data from all the clients. However...this did not fix the problem. Instead of crashing immediately on connect, when the 4th client connects he spits out a bunch of receive error 10040 codes which are defined as

Message too long. A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram was smaller than the datagram itself.

Weird..I thought. Just in case the buffer was too small, I set up the server to send 256''s still but the client instead to reeceive char[384]''s. However, this didn''t fix the problem. Any ideas or should I just put on the tough debugging gloves for both the server and the client?
I''m stupid and figured it out

This topic is closed to new replies.

Advertisement