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
- openTCPServerSocketWithOpts :: [(SocketOption, SockOptValue)] -> 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
- openClientSocketWithOpts :: [(SocketOption, SockOptValue)] -> 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.
runTCPServerWithSocket Source #
Running a TCP client with a connected socket for a given listen socket.
openTCPServerSocketWithOptions :: [(SocketOption, Int)] -> AddrInfo -> IO Socket Source #
Open socket for server use, and set the provided options before binding.
This is equivalent to
openTCPServerSocketWithOpts
.map
(second
SockOptValue
)
openTCPServerSocketWithOpts :: [(SocketOption, SockOptValue)] -> 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.
openClientSocket :: AddrInfo -> IO Socket Source #
This is the same as
openClientSocketWithOptions
[]
openClientSocketWithOptions :: [(SocketOption, Int)] -> AddrInfo -> IO Socket Source #
Open a client socket with the given options
The options are set before connect
. This is equivalent to
openClientSocketWithOpts
.map
(second
SockOptValue
)
openClientSocketWithOpts :: [(SocketOption, SockOptValue)] -> AddrInfo -> IO Socket Source #
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
.