YAP 7.1.0
SICStus compatible socket library

uses SWI code More...

Detailed Description

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:

Todo:
Our implementation does not support AF_UNIX sockets
Todo:
Implement socket_select/5
See also
http://www.sics.se/sicstus/@ref docs/3 .7.1/html/sicstus_28.html

Class Documentation

◆ current_host/1

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

◆ hostname_address/2

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

◆ socket_accept/3

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

◆ socket_accept/2

class socket_accept/2

socket_accept(+ SOCKET, - STREAM)

Accept a connection but do not return client information

◆ socket_bind/2

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:

  • 'AF_UNIX'(+ FILENAME) (unsupported)
  • 'AF_FILE'(+ FILENAME) use file name FILENAME for UNIX or local sockets
  • 'AF_INET'(? HOST,?PORT) If HOST is bound to an atom, bind to host HOST, otherwise if unbound bind to local host ( HOST remains unbound) If port PORT is bound to an integer, try to bind to the corresponding port If variable PORT is unbound allow operating systems to choose a port number, which is unified with PORT

◆ socket_close/1

class socket_close/1

socket_close(+ SOCKET)

Close socket SOCKET Note that sockets used in socket_connect (that is, client sockets) should not be closed with socket_close, as they will be automatically closed when the corresponding stream is closed with close/1 or close/2

◆ socket_listen/2

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

◆ socket_buffering/4

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

◆ socket_select/5

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