Hello all,

I try to make my program behave politely by releasing discarded
server sockets. Unfortunately this never happens. With the simple
code below, the program cannot be rerun, as it fails with an
"Address already in use".

-----
import Socket
import SocketPrim ( sClose )
import System
import IO


main = do sock <- listenOn (PortNumber $ mkPortNumber 47004)
          (handle,host) <- accept sock
          hPutStr handle ("Hello " ++ host ++ "\n")
          hClose handle
          sClose sock
-----

The program computes correctly, but won't release the address.
How on earth can I make my program give up that address?

/Anders

Reply via email to