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

So...

Started by Karl G Jul 14, 2003 at 10:42 AM 4 replies 450+ views
Original Post
Karl G
Karl G
Being as UDP Winsock is so "great" can anyone tell me where to find solid code for a server/client application that manages asynchronous connections? I''ve tried just about every tutorial/sample code on the net, including the one here on GameDev which was by far the most useful but it was TCPIP. It seems everyone else managed to get tutorials...so where''s that magic box? Karl
fingh
fingh
quote:
Original post by Karl G
Being as UDP Winsock is so "great" can anyone tell me where to find solid code for a server/client application that manages asynchronous connections?

I''ve tried just about every tutorial/sample code on the net, including the one here on GameDev which was by far the most useful but it was TCPIP. It seems everyone else managed to get tutorials...so where''s that magic box?



I''m curious why you need to ''manage asynchronous connections'' with UDP, since UDP is inherently connectionless? Try UDP without all the Microsoft specific stuff first, you might be surprised at how well it can perform.

Karl G
Karl G
Thanks for your reply, but I need a tutorial. Maybe I should explain a bit better?

I need to create a server that can manage a sustained chat where players can connect or disconnect and exchange information without "blocking" (ie not like the tutorial presented here on gamedev does. It waits for input from a player, then when it gets it waits for input for the second player...etc, then processes the information, and starts again)

I can''t have this because it needs to be a realtime environment. Could you give me a link...to anything?
fingh
fingh
Ok, that does not require using asynchronous IO. You can do that using non-blocking sockets, or by using blocking sockets with select(). I''d recommend nonblocking for UDP.

set the socket nonblocking with ioctlsocket(), passing it the FIONBIO option
Since you''re using UDP, you have only one socket on the server, so call recvfrom() and check the return value. If it''s SOCKET_ERROR, the check the error code with WSAGetLastError() and compare to WSAEWOULDBLOCK. You either get data, or it returns this error which means there''s no data there. Since there''s no data, go ahead and do whatever other processing you need to do (read the keyboard maybe? send outgoing data etc).
Karl G
Karl G
Thanks very much! That''s really helpful
zfod
zfod
Heh,

There is a virtual cockload of information on Winsock on the ''Net with copious examples.

Search hard.


.zfod

Topic Locked

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

Sign in to reply to this topic.