Sign in to follow this  
Cosmy

question about udp protocol

Recommended Posts

Quote:
Original post by hplus0603
listen() and accept() are specific to stream sockets (like TCP) where you use send() and recv().

With UDP, you only use bind(), recvfrom() and sendto().


thank's

Share this post


Link to post
Share on other sites
you can use select() to see which socket has received data that hasn't been processed through a recvfrom().

if your socket is asynchronous (non blocking), if you call recvfrom() with the socket having no data pending, recvfrom() will return WSA_WOULDBLOCK, meaning it's received nothing. That's fine, it's not really an error, more like a warning, and you can ignore that error. Using select(), you can ensure your socket does have data pending and returns no error (for blocking sockets, recvfrom() will block the thread until data is received so that's a non-issue).

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