Sockets I/O
Author(s): Francisco Bueno.
This module provides two useful predicates for programming with sockets.
Usage and interface
- Library usage:
:- use_module(library(sockets_io)). - Exports:
- Predicates:
serve_socket/3, safe_write/2.
- Predicates:
- Imports:
- System library modules:
lists, sockets/sockets. - Packages:
prelude, nonpure, assertions, hiord, regtypes.
- System library modules:
Documentation on exports
PREDICATE
(True) Usage:serve_socket(Socket,Server,Handler)
Handles the streams associated to Socket calling Server on one request of each stream (as Server(Stream)), and Handler(Stream) if the stream is empty (connection closed).
- The following properties should hold at call time:
(sockets_io:socket/1)Socket is a socket id.
(basic_props:callable/1)Server is a term which represents a goal, i.e., an atom or a structure.
(basic_props:callable/1)Handler is a term which represents a goal, i.e., an atom or a structure.
PREDICATE
(True) Usage:safe_write(Stream,Term)
Writes Term to Stream in a way that it is safe for a socket connection on Stream.
- The following properties should hold at call time:
(streams_basic:stream/1)Stream is an open stream.
(basic_props:term/1)Term is any term.