[ ECLiPSe Stream I/O built-in.|Group Index|
Full Index]
connect(+Stream, +Address)
Connects a socket with the given address.
- +Stream
- Atom or integer.
- +Address
- Atom, integer or structure.
Description
connect/2 is a direct link to the connect(2) system call, available on
Berkeley systems. Stream must be a socket stream created with socket/3.
If the socket was created in the unix domain, Address must be an atom
which identifies the file associated with the socket. If Address is 0
and socket type is datagram, the socket is disconnected.
If the socket is in the internet domain, the address is in the form
HostName/Port, where the atom HostName denotes the host to be connected
on the given integer port Port. If Address is 0/0 and socket type is
datagram, the socket is disconnected.
Every socket communication in ECLiPSe requires at least one of every two
communicating processes to call connect/2, because system calls to
perform direct datagram addressing are not available. The socket
connection can be queried with get_stream_info(s, connection, C).
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.
Datagram sockets require a connect/2 call from the process that wants to
write on the socket and bind/2 from the one that reads from it.
Fail Conditions
Fails if Address is HostName/Port and HostName does not unify with the
name of the host machine.
Resatisfiable
No.
Exceptions
- (4) Instantiation fault
- Stream or Address is not instantiated.
- (5) Type error
- Stream is instantiated, but not to an atom or an integer.
- (5) Type error
- Address is instantiated but not to the form accepted by the socket domain.
- (6) Range error
- Address is a nonzero integer.
- (170)
- It was not possible to connect the socket.
Examples
Success:
Error:
bind(s, Host/p) (Error 5).
bind(s, '/usr/bin') (Error 170).
See Also
socket / 3, listen / 2, accept / 3, connect / 2, current_stream / 1, get_stream_info / 3