Reputation: 3457
I have a TCP server application which listens for connections from clients that send "heartbeat" packets frequently in rather small intervals, around 20 seconds. There are a few hundred such clients, 1000 at most.
It has previously been implemented (not by me) such that a new TCP connection is established for every heartbeat, then it is closed.
It seems to me that it would be better to keep the connection open and reuse it for the communication, but I'm not sure. Is re-establishing the connections a waste of time and bandwidth and keeping a few hundred open connections (in the server's case) not a problem, or, on the contrary, is it a big waste of resources not to close them?
Upvotes: 2
Views: 514
Reputation: 123280
It depends on the amount of memory you have, of the latency of the connection and of the frequency of the heartbeat what the best options is:
Upvotes: 2