Go to the previous, next section.
This library package defines a number of predicates manipulating
sockets. They are all rather straight-forward interfaces to the
corresponding C-library predicates with the same name (except
current_host/1
). The reader should therefore study the C-manual
for a deeper description.
The Domain, is either the atom 'AF_INET'
or
'AF_UNIX'
. They correspond directly to the same domains in UNIX.
An Address is either 'AF_INET'(Host,Port)
or
'AF_UNIX'(SocketName)
. Host is an atomic hostname,
Port is a portnumber and SocketName is an atom denoting a
socket. A reader familiar with UNIX's sockets will understand this
immediately.
All streams below can be both read from and written on. All IO-predicates
operating on streams can be used, for example read/2
, write/2
,
format/3
, current_stream/3
, etc. Socket streams are unbuffered
on reads and block buffered on writes.
To load the package, enter the query
| ?- use_module(library(sockets)).
off
, the predicate waits until
something is available. If TimeOut is S:U
the predicate
waits at most S
seconds and U
microseconds. Both S
and U
must be integers >=0. If there is a timeout,
ReadStreams is []
. If Socket is instantiated,
socket_select/5
also waits for connections to this socket. If a
connection is found, NewStream will be a stream for communicating
with the connecting process.
Note that instead of this predicate the built-in stream_select/3
must be used in all cases when Socket is not used.
Go to the previous, next section.