2.1 library(tipc/tipc): TIPC Sockets
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • Transparent Inter-Process Communications (TIPC) libraries
        • The TIPC libraries: library(tipc/...)
          • library(tipc/tipc): TIPC Sockets
            • tipc_socket/2
            • tipc_close_socket/1
            • tipc_open_socket/3
            • tipc_bind/3
            • tipc_listen/2
            • tipc_accept/3
            • tipc_connect/2
            • tipc_get_name/2
            • tipc_get_peer_name/2
            • tipc_setopt/2
            • tipc_receive/4
            • tipc_send/4
            • tipc_canonical_address/2
            • tipc_service_exists/2
            • tipc_service_exists/1
            • tipc_service_probe/1
            • tipc_service_probe/2
            • tipc_service_port_monitor/2
            • tipc_service_port_monitor/3
            • tipc_initialize/0
Availability::- use_module(library(tipc/tipc)).
[det]tipc_receive(+Socket, -Data, -From, +OptionList)
Waits for, and returns the next datagram. Like its UDP counterpart, the data are returned as a Prolog string object (see string_codes/2). From is an address structure of the form port_id/2, indicating the sender of the message.

Defined options are:

as(+Type)
Defines the returned term-type. Type is one of atom, codes or string (default).
nonblock
Poll the socket and return immediately. If a message is present, it is returned. If not, then an exception, error(socket_error(eagain, Message), _), will be thrown. Users are cautioned not to "spin" unnecessarily on non-blocking receives as they may prevent the system from servicing other background activities such as XPCE event dispatching.

The typical sequence to receive a connectionless TIPC datagram is:

receive :-
        tipc_socket(S, dgram),
        tipc_bind(S, name(18888, 10, 0), scope(zone)),
        repeat,
            tipc_receive(Socket, Data, From, [as(atom)]),
            format('Got ~q from ~q~n', [Data, From]),
            Data == quit,
        !, tipc_close_socket(S).