Library to support network programming with sockets.
In standard applications, the server side uses the operations
listenOn
and socketAccept
to provide some service
on a socket, and the client side uses the operation
connectToSocket
to request a service.
Author: Michael Hanus
Version: December 2018
listenOn
:: Int -> IO Socket
Creates a server side socket bound to a given port number. |
listenOnFresh
:: IO (Int,Socket)
Creates a server side socket bound to a free port. |
accept
:: Socket -> IO (String,Handle)
Returns a connection of a client to a socket. |
waitForSocketAccept
:: Socket -> Int -> IO (Maybe (String,Handle))
Waits until a connection of a client to a socket is available. |
close
:: Socket -> IO ()
Closes a server socket. |
connectToSocket
:: String -> Int -> IO Handle
Creates a new connection to a Unix socket. |
Constructors:
Creates a server side socket bound to a free port. The port number and the socket is returned.
|
Returns a connection of a client to a socket. The connection is returned as a pair consisting of a string identifying the client (the format of this string is implementation-dependent) and a handle to a stream communication with the client. The handle is both readable and writable. Only IPv4 connections are currently possible. |
Waits until a connection of a client to a socket is available. If no connection is available within the time limit, it returns Nothing, otherwise the connection is returned as a pair consisting of a string identifying the client (the format of this string is implementation-dependent) and a handle to a stream communication with the client.
|
Creates a new connection to a Unix socket. Only IPv4 connections are currently possible.
|