[ Stream I/O | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]
listen(+Stream, +Queue)
Specifies how many connections are accepted for a socket and makes
connections available.
- +Stream
- Atom or integer.
- +Queue
- An integer.
Description
listen/2 is a direct link to the listen(2) system call, available on
Berkeley systems. Stream must be a socket stream created with socket/3
of the type stream. Queue specifies the length of the connection queue,
i.e. how many connections are allowed for this socket. After the call
to listen/2, other processes can call connect/2 to connect with this
socket, but the I/O is possible only after the server process creates
the new socket using accept/3.
Stream sockets are connected using the standard sequence, i.e.
socket/3, bind/2, listen/2 and accept/3 on the server and socket/3 and
connect/2 on the client. After the sockets are connected, both
processes can use them for reading and writing.
Fail Conditions
None.
Resatisfiable
No.
Exceptions
- (4) instantiation fault
- Stream or Queue is not instantiated.
- (5) type error
- Stream is instantiated, but not to an atom or an integer.
- (5) type error
- Queue is instantiated but not to an integer.
- (170) system interface error
- It was not possible to execute the system call.
Examples
Success:
socket(internet, stream, s), bind(s, Addr), listen(s, 1).
Error:
listen(s, N) (Error 4).
listen(s, 1.0) (Error 5).
listen(null, 2) (Error 170).
See Also
socket / 3, bind / 2, accept / 3, connect / 2, new_socket_server / 3