konteck / wpp

Single file embedded C++ web server
http://konteck.github.com/wpp
93 stars 47 forks source link

[Question]: How to terminate the main loop #18

Open urban-1 opened 6 years ago

urban-1 commented 6 years ago

Hi there,

I have been using this web server for a while and works for what I need, however, when I am restarting my main app too fast I cannot re-bind the port/socket. The TCP is in *_WAIT state:

$ netstat -tn | grep 8282
tcp4       0      0  127.0.0.1.8282         127.0.0.1.63878        FIN_WAIT_2
tcp4       0      0  127.0.0.1.63878        127.0.0.1.8282         CLOSE_WAIT
tcp4       0      0  127.0.0.1.63877        127.0.0.1.8282         TIME_WAIT

Is there a way to gracefully terminate the server? Am I doing something wrong?

Thanks