![]() |
YAP 7.1.0
|
uses SWI code More...
uses SWI code
YAP includes a SICStus Prolog compatible socket interface In YAP-6.3 this uses the clib
package to emulate the old low level interface that provides direct access to the major socket system calls These calls can be used both to open a new connection in the network or connect to a networked server Socket connections are described as read/write streams, and standard Input/Output built-ins can be used to write on or read from sockets The following calls are available:
class current_host/1 |
current_host(? HOSTNAME)
Unify HOSTNAME with an atom representing the fully qualified hostname for the current host Also succeeds if HOSTNAME is bound to the unqualified hostname
class hostname_address/2 |
hostname_address(? HOSTNAME,? IP_ADDRESS)
HOSTNAME is an host name and IP_ADDRESS its IP address in number and dots notation
class socket_accept/3 |
socket_accept(+ SOCKET, - CLIENT, - STREAM)
Interface to system call accept
, used for servers to wait for connections at socket SOCKET The stream descriptor STREAM represents the resulting connection If the socket belongs to the domain AF_INET
, CLIENT unifies with an atom containing the IP address for the client in numbers and dots notation
class socket_accept/2 |
socket_accept(+ SOCKET, - STREAM)
Accept a connection but do not return client information
class socket_bind/2 |
socket_bind(+ SOCKET, ? PORT)
Interface to system call bind
, as used for servers: bind socket to a port Port information depends on the domain:
class socket_close/1 |
class socket_listen/2 |
socket_listen(+ SOCKET, + LENGTH)
Interface to system call listen
, used for servers to indicate willingness to wait for connections at socket SOCKET The integer LENGTH gives the queue limit for incoming connections, and should be limited to 5
for portable applications The socket must be of type SOCK_STREAM
or SOCK_SEQPACKET
class socket_buffering/4 |
socket_buffering(+ SOCKET, - MODE, - OLD, + NEW)
Set buffering for SOCKET in read
or write
MODE OLD is unified with the previous status, and NEW receives the new status which may be one of unbuf
or fullbuf
class socket_select/5 |
socket_select(+ SOCKETS, - NEWSTREAMS, + TIMEOUT, + STREAMS, - READSTREAMS)
[unsupportedinYAP-6.3]
Interface to system call select
, used for servers to wait for connection requests or for data at sockets The variable SOCKETS is a list of form KEY-SOCKET, where KEY is an user-defined identifier and SOCKET is a socket descriptor The variable TIMEOUT is either off
, indicating execution will wait until something is available, or of the form SEC-USEC, where SEC and USEC give the seconds and microseconds before socket_select/5 returns The variable SOCKETS is a list of form KEY-STREAM, where KEY is an user-defined identifier and STREAM is a stream descriptor
Execution of socket_select/5 unifies READSTREAMS from STREAMS with readable data, and NEWSTREAMS with a list of the form KEY-STREAM, where KEY was the key for a socket with pending data, and STREAM the stream descriptor resulting from accepting the connection