TL;DR
I see that my sockets are in TIME_WAIT
with the ss
tool in Ubuntu 1804
, but I can't find in the docs for boost sockets or on SO how to set the time delay to 0
such that the socket immediately closes (or better yet, set it to an arbitrarily small value for my application.
I am writing a socket application with Boost asio. Both the client and the server are using boost sockets. I see that, when the client sends a shutdown connection command: mysocket.shutdown( boost::asio::ip::tcp::socket::shutdown_both, error_code);
, and my client C++ application closes down a 2 seconds later, I get TIME_WAIT
on the output of ss -ap | grep application_port
. I have been looking around SO and the internet looking for ways to set TIME_WAIT
with Boost C++, but instead, I keep finding questions for why a TIME_WAIT
happens.
Here are some:
https://stackoverflow.com/questions/14666740/receive-data-on-socket-in-time-wait-state
https://stackoverflow.com/questions/35006324/time-wait-with-boost-asio
https://stackoverflow.com/questions/47528798/closing-socket-cause-time-wait-pending-state
If I am interpreting the internet correctly (and the TCP protocol), the reason why TIME_WAIT happens is because the server connection is waiting for an ACK to allow for the socket conn to die, while the client-side socket has already died.
The question, again: