Jump to content
  • Advertisement
Sign in to follow this  
GCoda

winsock send blocks

This topic is 4745 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I was testing my winsock based networking interface and sending packets size of 10 - 500 almost every frame to server and eventually the send would block. So did it break some OS limit? I'm using windows XP. And coding with c++, but that shouldn't matter. This is what Msdn says about send(): "If no buffer space is available within the transport system to hold the data to be transmitted, send will block unless the socket has been placed in nonblocking mode." Is there anything else to do than send less packets? I'm only sending this much to test but would also like to prevent send from blocking. Is there anyway to observe monitor the system's buffer space so that I could add error checking code instead of calling send ending in a endless loop? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Hi,

Check out question #11 on the Forum FAQ. Sockets are in blocking mode my default. Look at using the select(..); it's the easiest of non-blocking methods to use.

Later,

GCS584

Share this post


Link to post
Share on other sites
Thanks gcs584. I'm using select() to check when it's ok to recv() but calling send() freely. This seems to work now after I fixed couble bugs and the send hasn't blocked anymore, even I'm not using select before it. Would it be safe to assume that send() doesn't require select() and only recv() does?

Thank you.

Share this post


Link to post
Share on other sites
If the server isn't able to process the data as fast the client sends it, then the server's buffer will eventually fill up, and sends on the client will block until space becomes available (i.e. when the server catches up).

So just to be on the safe side, you should ensure your sends don't block (by putting them in non-blocking mode, or using select).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!