
On Thu, Apr 11, 2013 at 12:33 AM, Niklas Hambüchen
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[1] and the comments on `Network.listenOn`[2]. You most likely want to set the `ReuseAddr` option to 1 on your socket with`Network.Socket.setSocketOption`.[3] [1]: http://www.haskell.org/pipermail/beginners/2010-June/004334.html [2]: http://hackage.haskell.org/packages/archive/network/2.4.1.2/doc/html/Network... [3]: http://hackage.haskell.org/packages/archive/network/2.4.1.2/doc/html/Network...