Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

FrancoisSoft

WinSock Question

This topic is 5759 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

Does the recv() function wait for the send() function to send it data or does recv() try to recv() data that doesn''t exist? In other words do the 2 functions wait for eachother? Hey, don''t forget to visit my page... by clicking here!

Share this post


Link to post
Share on other sites
Advertisement
Theres also the concept of blocking vs non-blocking sockets.

Basically, if a socket is blocking (default for winsock I think), recv()s will wait until there is actually data available or a timeout occurs. That is not to say they will wait until ALL the data is available. You may still need to call them until all of the expected data arrives.

For non-blocking sockets, a call to recv() will return as much data as available that instant. It could be 0.

see select() too.

Share this post


Link to post
Share on other sites
recv() defaults to blocking, yes, which means it waits for a packet to be recv''d. As far as i know (and i''ve looked), there is no timeout to recv(). So, unless you''re doing non-blocking sockets, calling recv() every frame or iteration or whatever would probably be not good.

if you need to call recv() every frame and need blocking sockets (this is what i do), use select with a time value of 0:0 seconds. works well for me...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!