L
L
Leo2014-08-28 12:56:24
Python
Leo, 2014-08-28 12:56:24

How to check that the client has fallen off?

I am writing my own UDP server in Python, there will be a lot of clients, it is desirable to determine which of them has disconnected so as not to send messages to them.
Hence, the question is how to do it (I'm interested in the algorithm itself)?
So far, I see it this way: the client sends messages to the server, like "I'm online", while the server disconnects those clients whose waiting time has passed. Then what interval of sending messages to choose? But this can make a good ddos ​​server.
Now I came up with another way - the activity of clients is kept, if it is less than the selected time interval, then the server itself sends a message to the client ("are you online?"). If the client does not respond, then the server removes it from the list.
I'm sure you have some other ideas about this.
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xmoonlight, 2014-08-28
@xmoonlight

If you use UDP, then delivery is not important to you.
Otherwise - would use TCP.
And so - telephony standard)) Two ports: one - voice (UDP), the other - signaling (TCP).
Here on the signaling and drive pings, and UDP - sent and forgotten.

S
s1dney, 2014-08-28
@s1dney

Yes, the person above said everything correctly - it's a thankless task to support via UDP keepalive, use one more tcp socket for control. Or maybe just refuse UDP.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question