Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

JJTricky

Detecting client timeouts on a non-blocking server (MMORPG)

This topic is 5218 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I would like to implement this on the server side. select() is being used to monitor the updating sockets/clients. The problem I have is that I want to time the clients that are not updating and purge them every 5 minutes or so. I figure perhaps I can update a timeout variable in the client class on every round of updates but this requires getting at the clients that select() does not select and I can''t think of how to do this efficiently. Then every 5 min or so, the server can go through all the clients and disconnect them appropriately. Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
Even if a client doesn''t send you data, you probably send it data every so often (because other players move, or mobs spawn, or whatever). Thus, you can check whether you''ve seen a packet for the last N seconds from the client, when sending to the client. If not, disconnect.

Another way to do it is to keep an event in an event queue for each client. Add it N seconds in the future when you create each client. When you receive data from a client, remove its event, and re-add it N seconds into the future from the point in time you received the data from the client. After each select(), service all events whose time is no longer in the future. When servicing a timeout event, disconnect the client.

Don''t forget to remove the timeout event when a client disconnects normally :-)

Share this post


Link to post
Share on other sites
You could detect errors on the socket when sending data or send a ping packet every 5 minutes(And post-pone this packet once data is arrived). Usually, if a client is disconnected the hard way, the socket-tunnel will usually collapse within 5 - 10 minutes(From my experience). Once the tunnel collapsed, sending a packet generates an error. At this point, you close the connection.

Toolmaker



My site
/* -Earth is 98% full. Please delete anybody you can.*/

Share this post


Link to post
Share on other sites
If you''re using UDP, they are connectionless, and you can''t detect connection loss through an error.

For TCP, when a client disconnects, or if the software crashes, the kernel will typically send a TCP reset, which will immediately close the connection on your end, so you''ll get an immediate error. Only when there is network failure will you see a mysterious time-out without activity under TCP.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!