[Haskell-cafe] Web servers: Running them multiple times in a ghci session
targen at gmail.com
Thu Apr 11 08:25:30 CEST 2013
On Thu, Apr 11, 2013 at 12:33 AM, Niklas Hambüchen <mail at nh2.me> wrote:
> I'm writing a web server app, which I run in ghci:
> :main localhost 8000
> Unfortunately, after Ctrl-C and :reload, running it again:
> ** Exception: bind: resource busy (Address already in use)
> This is pretty annoying, because quitting-and-restarting takes a lot of
> time since I have many dependencies.
> How do you deal with this? Can you propose some working code that can be
> wrapped around my main function to make it work?
Just a guess: it probably has to do with `SO_REUSEADDR`; see this old
thread and the comments on `Network.listenOn`. You most likely
want to set the `ReuseAddr` option to 1 on your socket
More information about the Haskell-Cafe