c++ - Socket is open after process, that opened it finished -


after closing client socket on sever side , exit application, socket still open time.

i can see via netstat

every 0.1s: netstat -tuplna  | grep 6676     tcp        0      0 127.0.0.1:6676          127.0.0.1:36065         time_wait   - 

i use log4cxx logging , telnet appender. log4cxx use apr sockets. socket::close() method looks that:

void socket::close() {     if (socket != 0) {         apr_status_t status = apr_socket_close(socket);         if (status != apr_success) {             throw socketexception(status);         }                 socket = 0;     } } 

and it's processed. after program finished can see opened socket via netstat, , if starts again log4cxx unable open 6676 port, because busy. tries modify log4cxx. shutdown socket before close:

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;     } } 

but didn't helped, bug still reproduced.

this not bug. time wait (and close wait) design safety purpose. may adjust wait time. in case, on server's perspective socket closed , relax ulimit counter, has not visible impact unless doing stress test.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -