question about udp protocol
so, a last day i wrote a winsock wrapper using udp protocol
but listen() and accept() don't work; work only with tcp protocol?
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().
With UDP, you only use bind(), recvfrom() and sendto().
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
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).
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).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement