-- 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.4.4

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

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

-- | Running a TCP client with a connected socket for a given listen
--   socket.
runTCPServerWithSocket :: Socket -> (Socket -> IO a) -> IO a

-- | Open TCP socket for server use
--   
--   This is the same as:
--   
--   
--   openTCPServerSocketWithOptions []
--   
openTCPServerSocket :: AddrInfo -> IO Socket

-- | Open socket for server use, and set the provided options before
--   binding.
--   
--   This is equivalent to
--   
--   
--   openTCPServerSocketWithOpts . map (second SockOptValue)
--   
openTCPServerSocketWithOptions :: [(SocketOption, Int)] -> AddrInfo -> IO Socket

-- | Open socket for server use, and set the provided options before
--   binding.
--   
--   In addition to the given options, the socket is configured to
--   
--   
--   
- allow reuse of local addresses (SO_REUSEADDR)
--   
- automatically be closed during a successful execve
--   (FD_CLOEXEC)
--   
- bind to the address specified
--   
- listen with queue length with 1024
--   
openTCPServerSocketWithOpts :: [(SocketOption, SockOptValue)] -> AddrInfo -> IO Socket
resolve :: SocketType -> Maybe HostName -> ServiceName -> [AddrInfoFlag] -> (NonEmpty AddrInfo -> AddrInfo) -> IO AddrInfo

-- | Running a TCP client with a connected socket.
--   
--   This is the same as:
--   
--   
--   runTCPClientWithSettings defaultSettings
--   
runTCPClient :: HostName -> ServiceName -> (Socket -> IO a) -> IO a

-- | Settings for client.
data Settings

-- | Default settings.
defaultSettings :: Settings

-- | Opening a socket. Use openClientSocketWithOptions to specify
--   SocketOption
settingsOpenClientSocket :: Settings -> AddrInfo -> IO Socket

-- | Selecting AddrInfo.
settingsSelectAddrInfo :: Settings -> NonEmpty AddrInfo -> AddrInfo

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

-- | This is the same as
--   
--   
--   openClientSocketWithOptions []
--   
openClientSocket :: AddrInfo -> IO Socket

-- | Open a client socket with the given options
--   
--   The options are set before connect. This is equivalent to
--   
--   
--   openClientSocketWithOpts . map (second SockOptValue)
--   
openClientSocketWithOptions :: [(SocketOption, Int)] -> AddrInfo -> IO Socket

-- | Open a client socket with the given options
--   
--   This must be used rather than openClientSocketWithOptions for
--   options such as Linger which require a composite value
--   (StructLinger).
--   
--   The options are set before connect.
openClientSocketWithOpts :: [(SocketOption, SockOptValue)] -> AddrInfo -> IO Socket

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

-- | Running a TCP server with a connected socket.
runTCPServer :: Int -> Maybe HostName -> ServiceName -> TimeoutServer a -> IO a

-- | A server type
type TimeoutServer a = Manager -> Handle -> Socket -> IO a

-- | Running a TCP client with a connected socket for a given listen
--   socket.
runTCPServerWithSocket :: Int -> Socket -> TimeoutServer a -> IO a

-- | Open socket for server use
--   
--   This is the same as:
--   
--   
--   openServerSocketWithOptions []
--   
openServerSocket :: AddrInfo -> IO Socket

-- | Open socket for server use, and set the provided options before
--   binding.
--   
--   This is equivalent to
--   
--   
--   openServerSocketWithOpts . map (second SockOptValue)
--   
openServerSocketWithOptions :: [(SocketOption, Int)] -> AddrInfo -> IO Socket

-- | Open socket for server use, and set the provided options before
--   binding.
--   
--   In addition to the given options, the socket is configured to
--   
--   
--   
- allow reuse of local addresses (SO_REUSEADDR)
--   
- automatically be closed during a successful execve
--   (FD_CLOEXEC)
--   
- bind to the address specified
--   
openServerSocketWithOpts :: [(SocketOption, SockOptValue)] -> 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 sendTo.
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 addrS:portS and a client connects to the service
--   from addrC:portC. A connected socket is created by binding to
--   *:portS and connecting to addrC:portC, resulting in
--   (UDP,addrS:portS,addrC:portC) where addrS is given
--   magically. This approach is fragile due to NAT rebidings.
runUDPServerFork :: [HostName] -> ServiceName -> (Socket -> ByteString -> IO ()) -> IO ()
