-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Simple network runner library
--   
--   Simple functions to run network clients and servers.
@package network-run
@version 0.2.8


-- | Simple functions to run TCP clients and servers.
module Network.Run.TCP

-- | Running a TCP client with a connected socket.
runTCPClient :: HostName -> ServiceName -> (Socket -> IO a) -> IO a

-- | Running a TCP server with an accepted socket and its peer name.
runTCPServer :: Maybe HostName -> ServiceName -> (Socket -> IO a) -> IO a

-- | Generalization of <a>runTCPServer</a>
runTCPServerWithSocket :: (AddrInfo -> IO Socket) -> Maybe HostName -> ServiceName -> (Socket -> IO a) -> IO a

-- | Open socket for server use
--   
--   The socket is configured to
--   
--   <ul>
--   <li>allow reuse of local addresses (SO_REUSEADDR)</li>
--   <li>automatically be closed during a successful <tt>execve</tt>
--   (FD_CLOEXEC)</li>
--   <li>bind to the address specified</li>
--   </ul>
openServerSocket :: AddrInfo -> IO Socket


-- | Simple functions to run TCP clients and servers.
module Network.Run.TCP.Timeout

-- | Running a TCP server with an accepted socket and its peer name.
runTCPServer :: Int -> Maybe HostName -> ServiceName -> TimeoutServer a -> IO a

-- | A server type
type TimeoutServer a = -- | A global timeout manager Manager -> -- | A thread-local timeout handler Handle -> -- | A connected socket Socket -> IO a

-- | Generalization of <a>runTCPServer</a>
--   
--   See <a>runTCPServerWithSocket</a> for additional discussion.
runTCPServerWithSocket :: (AddrInfo -> IO Socket) -> Int -> Maybe HostName -> ServiceName -> TimeoutServer a -> IO a
openClientSocket :: AddrInfo -> IO Socket

-- | Open socket for server use
--   
--   The socket is configured to
--   
--   <ul>
--   <li>allow reuse of local addresses (SO_REUSEADDR)</li>
--   <li>automatically be closed during a successful <tt>execve</tt>
--   (FD_CLOEXEC)</li>
--   <li>bind to the address specified</li>
--   </ul>
openServerSocket :: AddrInfo -> IO Socket


-- | Simple functions to run UDP clients and servers.
module Network.Run.UDP

-- | Running a UDP client with a socket. The client action takes a socket
--   and server's socket address. They should be used with <a>sendTo</a>.
runUDPClient :: HostName -> ServiceName -> (Socket -> SockAddr -> IO a) -> IO a

-- | Running a UDP server with an open socket in a single Haskell thread.
runUDPServer :: Maybe HostName -> ServiceName -> (Socket -> IO a) -> IO a

-- | Running a UDP server with a connected socket in each Haskell thread.
--   The first request is given to the server. Suppose that the server is
--   serving on <b>addrS:portS</b> and a client connects to the service
--   from <b>addrC:portC</b>. A connected socket is created by binding to
--   <b>*:portS</b> and connecting to <b>addrC:portC</b>, resulting in
--   <b>(UDP,addrS:portS,addrC:portC)</b> where <b>addrS</b> is given
--   magically. This approach is fragile due to NAT rebidings.
runUDPServerFork :: [HostName] -> ServiceName -> (Socket -> ByteString -> IO ()) -> IO ()
