| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Network.Run.TCP
Description
Simple functions to run TCP clients and servers.
Synopsis
- runTCPServer :: Maybe HostName -> ServiceName -> (Socket -> IO a) -> IO a
- runTCPServerWithSocket :: Socket -> (Socket -> IO a) -> IO a
- openTCPServerSocket :: AddrInfo -> IO Socket
- openTCPServerSocketWithOptions :: [(SocketOption, Int)] -> AddrInfo -> IO Socket
- resolve :: SocketType -> Maybe HostName -> ServiceName -> [AddrInfoFlag] -> IO AddrInfo
- runTCPClient :: HostName -> ServiceName -> (Socket -> IO a) -> IO a
- data Settings
- defaultSettings :: Settings
- settingsOpenClientSocket :: Settings -> AddrInfo -> IO Socket
- runTCPClientWithSettings :: Settings -> HostName -> ServiceName -> (Socket -> IO a) -> IO a
- openClientSocket :: AddrInfo -> IO Socket
- openClientSocketWithOptions :: [(SocketOption, Int)] -> AddrInfo -> IO Socket
Server
runTCPServer :: Maybe HostName -> ServiceName -> (Socket -> IO a) -> IO a Source #
Running a TCP server with an accepted socket and its peer name.
This is the same as:
runTCPServerWithSocketOptions []
runTCPServerWithSocket Source #
Running a TCP client with a connected socket for a given listen socket.
openTCPServerSocket :: AddrInfo -> IO Socket Source #
Open TCP socket for server use
This is the same as:
openTCPServerSocketWithOptions []
openTCPServerSocketWithOptions :: [(SocketOption, Int)] -> AddrInfo -> IO Socket Source #
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
resolve :: SocketType -> Maybe HostName -> ServiceName -> [AddrInfoFlag] -> IO AddrInfo Source #
Client
runTCPClient :: HostName -> ServiceName -> (Socket -> IO a) -> IO a Source #
Running a TCP client with a connected socket.
This is the same as:
runTCPClientWithSettings defaultSettings
defaultSettings :: Settings Source #
Default settings.
settingsOpenClientSocket :: Settings -> AddrInfo -> IO Socket Source #
Opening a socket. Use openClientSocketWithOptions to specify SocketOption
runTCPClientWithSettings :: Settings -> HostName -> ServiceName -> (Socket -> IO a) -> IO a Source #
Running a TCP client with a connected socket.
openClientSocketWithOptions :: [(SocketOption, Int)] -> AddrInfo -> IO Socket Source #