Advertisement

Using UDP which is more effective for Nonblocking?

Started by January 10, 2003 10:31 PM
2 comments, last by Illumini 22 years ago
Something like this... (which i dont really understand but i''ve seen done) fcntl(socket, F_SETFL, O_NONBLOCK); Or using a FD_SET and calling select to see if I should recieve? (This is how I did it under TCP but since I only have one socket now is it overkill?) Thanks for input
I''d do both. If the program blocked data may not be received for a long time. Select or poll can be called with a timeout so the program can do other things if data hasn''t been received.

A turn based game server or a request/reply server could block but if the program is graphical the graphics might need to be updated even if nothing in the game has changed. The client window could get resized or need to be redrawn because another window passed over it.

kdIXfA.gamedev.10.coreyh@xoxy.net
www.ipeg.com/~rlfc
kdIXfA.gamedev.10.coreyh@xoxy.netwww.ipeg.com/~rlfc
Advertisement
You could just set to non-blocking with fcntl and call recv on it - if you get WOULDBLOCK, do something else and come back later.
This involves no timeouts so is good for a single threaded engine... I haven''t tried it in a real world situation yet though.


----------
http://www.zppz.com <- game dev stuff
The program should stop when it doesn''t have work to do.
kdIXfA.gamedev.10.coreyh@xoxy.netwww.ipeg.com/~rlfc

This topic is closed to new replies.

Advertisement