WinSock Question

Started by
2 comments, last by FrancoisSoft 21 years, 5 months ago
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!
Advertisement
They''re independent of each other.

You just have to call recv every iteration of so whether data has been sent or not.

Ben


IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting | Tiberian Merchandise!!!! | GameShot ]
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.
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...

This topic is closed to new replies.

Advertisement