• Advertisement
Sign in to follow this  

question about udp protocol

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

so, a last day i wrote a winsock wrapper using udp protocol but listen() and accept() don't work; work only with tcp protocol?

Share this post


Link to post
Share on other sites
Advertisement
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().

Share this post


Link to post
Share on other sites
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
Sign in to follow this  

  • Advertisement