Sockets I/O

Author(s): Francisco Bueno.

This module provides two useful predicates for programming with sockets.

Usage and interface

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.
Meta-predicate with arguments: serve_socket(?,(pred 1),(pred 1)).

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.