haskell - How do I terminate a socket server in ghci? -
i wrote webserver with, say, webserver package, , can start in ghci with:
:main localhost 8000
if ctrl-c , run again, get
*** exception: bind: resource busy (address in use)
so socket seems bound ghci session.
how can free port binding can :reload
, start again without quitting ghci?
this happens if underlying server implementation not set reuse_addr
option on socket.
usually if terminate server abruptly, operating system keeps server's old port in 2msl state couple of minutes in order prevent new servers on port accidentally receiving old messages intended previous connection. if set reuse_addr
when attempting bind port, specify wish forcefully reuse before 2msl period over.
the way can fix modify code underlying web server using set reuse_addr
option before binding listening socket.
Comments
Post a Comment