How to stop listening on an HTTP::Daemon port in Perl -


I have a basic perl HTTP server using. When I stop and start the script, That's still listening on the port and I'm getting an error message that my HTTP :: Daemon example is undefined. If I try to start a script about a minute about closing the script, then it works fine and can tie the port again.

Is there any way to stop listening to the port, when the program ends rather than ending, to wait for the time limit?

  Use HTTP :: daemon; Use HTTP :: status; My $ d = New HTTP :: Demon (LocalEditor = & gt; 'localhost', localport => 8000); While (my $ c = $ d-> accept) {while (my $ r = $ c-> get_request) {$ c-> send_error (RC_FORBIDDEN)} $ c-> Close; Undef ($ c); }  

Edit:

According to DVK's response, I $ d-> off () But I am getting the same error even while trying to restart my script.

  END {$ d-> close (); } $ SIG {'INT'} = 'CLEANUP'; $ SIG {__WARN__} = 'CLEANUP'; $ SIG {__ DIE__} = 'CLEANUP'; Sub cleanup {$ d-> off (); Undef ($ d); Print "\ n \ n caught interrupt (^ c), cancellation \ n"; Exit (1); }  

Resolve me your problem ReuseAddr = & gt; 1 when the HTTP :: daemon is created.

  My $ d = New HTTP :: Demon (Reuid => 1, LocalEditR = & gt; 'localhost', localport => 8000);  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -