question about udp protocol

Started by
2 comments, last by oliii 15 years, 4 months ago
so, a last day i wrote a winsock wrapper using udp protocol but listen() and accept() don't work; work only with tcp protocol?
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().
enum Bool { True, False, FileNotFound };
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).

Everything is better with Metal.

This topic is closed to new replies.

Advertisement