Avoid TIME_WAIT state, server side: wait for client to close connection.
See:
http://blog.netherlabs.nl/articles/2009/01/18/the-ultimate-so_linger-page-or-why-is-my-tcp-not-reliable
http://www.serverframework.com/asynchronousevents/2011/01/time-wait-and-its-design-implications-for-protocols-and-scalable-servers.html
http://stackoverflow.com/questions/3757289/tcp-option-so-linger-zero-when-its-required
By the way, never use SO_LINGER. The application level protocol should be implemented
in such way that allows the client side to find out when server side ended up sending
data and in this way the client is able to close the connectiond and server side does not
finish with sockets in TIME_WAIT state.