Question

I am running a local instance of HTTP::Daemon using a modified version of the looping structure outlined in the documentation. I have made it possible to exit the loop at the user's request, but a subsequent execution of my Perl script gives me the error:

HTTP::Daemon: Address already in use ...propagated at /path/to/script line NNN, line 3.

What more must I do to be a good citizen and clean up after my Daemon?

Was it helpful?

Solution

Most likely nothing. The address is in use by leftover connections from the previous instance. As soon as they are all shut down, the address will be automatically released.

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 details. "if a server dies without outstanding connections the port won't be immediately reusable unless you use the option SO_REUSEADDR using setsockopt() function."

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top