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: February 2008
| Exported names: |
Datatypes:
Socket
Functions:
connectToSocket
| listenOn
| listenOnFresh
| sClose
| socketAccept
| waitForSocketAccept
| Summary of exported functions: |
|
||
|
||
|
||
|
||
|
||
|
| Imported modules: |
| Exported datatypes: |
The abstract type of sockets.
Constructors:
| Exported functions: |
:: Int -> IO Socket
Creates a server side socket bound to a given port number.
:: IO (Int,Socket)
Creates a server side socket bound to a free port. The port number and the socket is returned.
:: Socket -> IO (String,Handle)
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.
:: Socket -> Int -> IO (Maybe (String,Handle))
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.
Example call: (waitForSocketAccept socket timeout)
socket
- a socket
timeout
- milliseconds to wait for input (< 0 : no time out)
:: Socket -> IO ()
Closes a server socket.
:: String -> Int -> IO Handle
Creates a new connection to a Unix socket.
Example call: (connectToSocket host port)
host
- the host name of the connection
port
- the port number of the connection