Advertisement

select() and datagram sockets

Started by January 25, 2004 09:38 PM
1 comment, last by Jasten 21 years ago
Greetings, Things are coming along pretty well for my senior project networking engine. I have a server client structure up and running that can communicate chat messages through stream sockets. Today I started the implimentation of the datagram sockets and found that for some reason the select() and FD_ISSET command is not working. I use it with stream sockets and it allows me to keep my functionality of the engine non blocking and makes life a whole lot easier. When i attempt to use it on a datagram socket as soon as i send a packet from the socket the FD_ISSET() macro always returns true. I was wondering if anyone could give me a heads up on if its possible to use these commands on a datagram socket or any work arounds for keeping the non blocking functionality of my datagram sockets. Thanks in advance, Daniel Doptis
u_long yes = 1;ioctlsocket(udpsock, FIONBIO, &yes); // make non-blocking 


From now on, calls to recvfrom and sendto (among others) will fail with WASEWOULDBLOCK if there''s nothing to receive or no room to send. It''s a "normal" error. It just means that instead of blocking, they return right away so your program can continue.
Advertisement
Thanks, I believe i remember seeing that somewhere before. From the tutorials ive read i was given the impression that making the sockets straight out non-blocking was bad and using select and the macros were better. Personally they both seem to have the same effect and im still a tad unclear of the benefits of select.

This topic is closed to new replies.

Advertisement