Did you know ... Search Documentation:
Pack ciao -- prolog/dialect/ciao/sockets.pl
PublicShow source

This library emulates library(sockets) from CIAO Prolog. One of the problems we are faced with here is that CIAO streams appear to be read/write, while SWI-Prolog streams are either input or output. For this reason, SWI-Prolog introduced stream_pair/3.

 hostname_address(+HostName, -Address) is det
Translate between HostName and Address. Address is an atom of the form XX.XX.XX.XX.
 socket_shutdown(+Stream, +How)
Shut down a duplex communication socket with which Stream is associated. All or part of the communication can be shutdown, depending on the value of How. The atoms read, write, or read_write should be used to denote the type of closing required.
 socket_recv_code(+Stream, ?String, ?Length)
Receives a String from the socket associated to Stream, and returns its Length. If Length is -1, no more data is available.
 socket_send(+Stream, +String)
Sends String to the socket associated to Stream. The socket has to be in connected state. String is not supposed to be NULL terminated, since it is a Prolog string. If a NULL terminated string is needed at the other side, it has to be explicitly created in Prolog.
 bind_socket(?Port, +Length, -Socket) is det
Returs an AF_INET Socket bound to Port (which may be assigned by the OS or defined by the caller), and listens to it (hence no listen call in this set of primitives). Length specifies the maximum number of pending connections.
 socket_accept(+Sock, -Stream) is det
Creates a new Stream connected to Sock.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 connect_to_socket(Arg1, Arg2, Arg3)
 socket_recv(Arg1, Arg2)