rugwuk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I've searched around and found some useful references for using HTTP::Daemon, and have got a simple web server up and running very easily using this module and the examples from Randall etc. I fork a child to do some work from the main daemon and that works just fine and dandy.

My problem is that sometimes (Solaris 2.8 BTW), when i kill my daemon during testing and start it again on the same PORT i get "Address already in use", and i can't seem to see why, as the process i was running is clearly dead.

Now its doesn't always fail, just sometimes. I scoped out netstat -a on my port and found a WAIT_TIME entry for my port number, but wasn't sure if this was related or not? eventually the PORT does become free, but i haven't managed to track down exactly when yet.

I know this isn't strictly perl, but it might be, and am trying to rule it out. Is there a particular way i should kill the process, currently just Ctrl C, to make sure that any hanging resources are released?

Thx in advance and Rgds Richard

Replies are listed 'Best First'.
•Re: HTTP:Daemon : Address already in use
by merlyn (Sage) on Jun 13, 2002 at 22:47 UTC
      Note that use of Reuse have been deprecated in latest Perls (5.6.1 ???). From perldoc IO::Socket::INET (base class of HTTP::Daemon):
      In addition to the key-value pairs accepted by IO::Socket, "IO::Socket::INET" provides. .... .... ReuseAddr Set SO_REUSEADDR before binding Reuse Set SO_REUSEADDR before binding (deprecated, prefer ReuseAddr) ReusePort Set SO_REUSEPORT before binding

      --
      Ilya Martynov (http://martynov.org/)

        Thx i'll try those tips.

        Richard