title: Socket is open after process, that opened it finished
body: <p>After closing client socket on sever side and exit application, socket still open for some time.</p>
  
  <p>I can see it via netstat</p>
  
  <pre><code>Every 0.1s: netstat -tuplna  | grep 6676    
  tcp        0      0 127.0.0.1:6676          127.0.0.1:36065         TIME_WAIT   -
  </code></pre>
  
  <p>I use log4cxx logging and telnet appender. log4cxx use apr sockets.
  Socket::close() method looks like that:</p>
  
  <pre><code>void Socket::close() {
      if (socket != 0) {
          apr_status_t status = apr_socket_close(socket);
          if (status != APR_SUCCESS) {
              throw SocketException(status);
          }        
          socket = 0;
      }
  }
  </code></pre>
  
  <p>And it's successfully processed. But after program is finished I can see opened socket via netstat, and if it starts again log4cxx unable to open 6676 port, because it is busy.
  I tries to modify log4cxx. 
  Shutdown socket before close:</p>
  
  <pre><code>void Socket::close() {
      if (socket != 0) {
          apr_status_t shutdown_status = apr_socket_shutdown(socket, APR_SHUTDOWN_READWRITE);
          printf("Socket::close shutdown_status %d\n", shutdown_status);
          if (shutdown_status != APR_SUCCESS) {
              printf("Socket::close WTF %d\n", shutdown_status != APR_SUCCESS);
              throw SocketException(shutdown_status);
          }
          apr_status_t close_status = apr_socket_close(socket);
          printf("Socket::close close_status %d\n", close_status);
          if (close_status != APR_SUCCESS) {
              printf("Socket::close WTF %d\n", close_status != APR_SUCCESS);
              throw SocketException(close_status);
          }
          socket = 0;
      }
  }
  </code></pre>
  
  <p>But it didn't helped, bug still reproduced.</p>