{- | Takes some options and sets up the 'SocketServer'.  I will bind
and begin listening, but will not accept any connections itself. -}
setupSocketServer :: InetServerOptions -> IO SocketServer
setupSocketServer opts =
    do proto <- getProtocolNumber (protoStr opts)
       s <- socket (family opts) (sockType opts) proto
       setSocketOption s ReuseAddr (case (reuse opts) of
                                    True -> 1
                                    False -> 0)
       bindSocket s (SockAddrInet (portNumber opts)
                     (interface opts))
       listen s (listenQueueSize opts)
       return $ SocketServer {optionsSS = opts, sockSS = s}

{- | Close the socket server.  Does not terminate active
handlers, if any. -}
setupSocketServer :: InetServerOptions -> IO SocketServer
setupSocketServer opts =
    do proto <- getProtocolNumber (protoStr opts)
       s <- socket (family opts) (sockType opts) proto
       setSocketOption s ReuseAddr (case (reuse opts) of
                                    True -> 1
                                    False -> 0)
       bindSocket s (SockAddrInet (portNumber opts)
                     (interface opts))
       listen s (listenQueueSize opts)
       return $ SocketServer {optionsSS = opts, sockSS = s}

{- | Close the socket server.  Does not terminate active
handlers, if any. -}
setupSocketServer opts =
    do proto <- getProtocolNumber (protoStr opts)
       s <- socket (family opts) (sockType opts) proto
       setSocketOption s ReuseAddr (case (reuse opts) of
                                    True -> 1
                                    False -> 0)
       bindSocket s (SockAddrInet (portNumber opts)
                     (interface opts))
       listen s (listenQueueSize opts)
       return $ SocketServer {optionsSS = opts, sockSS = s}

{- | Close the socket server.  Does not terminate active
handlers, if any. -}