How to clean up after my demon?

I am running a local instance of HTTP :: Daemon using a modified version of the loop structure described in the documentation. I allowed to exit the loop at the request of the user, but subsequent execution of my Perl script gives me an error:

HTTP :: Daemon: the address is already in use ... passed to / path / to / script line NNN, line 3.

What else should I do to become a good citizen and get out after my demon?

+4
source share
1 answer

Most likely nothing. The address is used when using the remaining connections from the previous instance. As soon as they are all disconnected, the address will be automatically freed.

If you want to speed up this process, you can set the SO_REUSEADDR socket option before binding. See the PERL socket documentation for more information. "if the server dies without outstanding connections, the port will not be immediately reused unless you use the SO_REUSEADDR parameter with the setsockopt () function.

+5
source

Source: https://habr.com/ru/post/1380102/


All Articles