user1002288
user1002288

Reputation: 5050

In TCP/IP sockets, how would the server know that a client is busy and not receiving data ?

In TCP/IP sockets, how would the server know that a client is busy and not receiving data ?

My solution:

Use connect(),

I am not sure.

thanks

Upvotes: 0

Views: 1359

Answers (2)

Chris Eberle
Chris Eberle

Reputation: 48795

A client will almost always receive your data, by which I mean the OS will accept the packets and queue them up for reading. If that queue fills up, then the sender will block (TCP, anyways). You can't actually know the activity of the client code. Pretty much your only option is to use timeouts.

Upvotes: 1

cnicutar
cnicutar

Reputation: 182794

In TCP/IP sockets, how would the server know that a client is busy and not receiving data

If a TCP is constantly pushing data that the peer doesn't acknowledge, eventually the send window will fill up. At that point the TCP is going to buffer data to "send later". Eventually the buffer size will be reached and send(2) will hang (something it doesn't usually do).

If send(2) starts hanging it means the peer TCP isn't acknowledging data.

Obviously, even if the peer TCP accepts data it doesn't mean the peer application actually uses it. You could implement your own ACK mechanism on top of TCP, and it's not as unreasonable as it sounds. It would involve having the client send a "send me more" message once in a while.

Upvotes: 2

Related Questions