Skip to main content
GameDev.net gamedev.net
🔒 Locked

question about udp protocol

Started by Cosmy Dec 19, 2008 at 11:16 AM 2 replies 900+ views
Original Post
Cosmy
Cosmy
so, a last day i wrote a winsock wrapper using udp protocol but listen() and accept() don't work; work only with tcp protocol?
hplus0603
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().
enum Bool { True, False, FileNotFound };
Cosmy
Cosmy
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

oliii
oliii
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.