1

If the server wants to close a connection, the server will have to wait TIME_WAIT seconds before its able to clean up the connection. Whereas if you tell the client to close the connection, the server side doesn't wait TIME_WAIT seconds because the client initiated it after server tells it to. Therefore the connection is instantly cleaned up on the server side. So wouldn't it make more sense to tell the client to close the connection instead of the server doing it so you lessen the odds of out of memory issues on server?

  • 1
    You should read [TIME_WAIT and its design implications for protocols and scalable client server systems](http://www.serverframework.com/asynchronousevents/2011/01/time-wait-and-its-design-implications-for-protocols-and-scalable-servers.html), as it directly addresses your question. – Remy Lebeau May 19 '21 at 00:25
  • It is better to be the end that receives the first close. That end doesn't enter TIME_WAIT. It isn't necessary to 'tell' the client to close first, as long as the clent *does* close first. which isn't hard to arrange. Normally connections should be used for multiple request/response cycles, after each one of which the server will be waiting for the next request. So if the client closes instead of sending another request, your condition is satisfied. – user207421 May 19 '21 at 00:41
  • @RemyLebeau Looks like I answered my own question. Thanks for the link. – CharlesOliveiraDoBronx May 24 '21 at 14:07

0 Answers0