Sign in to follow this  
GCoda

winsock send blocks

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this