[ ECLiPSe message passing built-in.|Group Index| Full Index]

mps_send(+Port, +Term)

Send the message Term to the specified Port.

+Port
A port identifier (integer).
+Term
An arbitrary Prolog term.

Description

ECLiPSe message passing supports asynchronous non-blocking point-to-point communication in heterogeneous environments. The end-points of communication are ports, i.e. messages are sent to and received from ports. Messages are arbitrary Prolog terms.

mps_send/2 sends a message to a specified port. The port identifier was usually obtained either by name server lookup, or it has been communicated to the sender by an earlier message.

Fail Conditions

None.

Resatisfiable

No.

Exceptions

(4) Instantiation fault
Port is not instantiated.
(5) Type error
Port is not an integer.
(176)
Message passing system error.

Examples


% code on server

    server(NsrvHost) :-
	mps_init(NsrvHost),
	mps_port_allocate(true/0, RequestPort),
	mps_port_register("SampleServer", "RunGoal", "Sig", RequestPort),
	server_loop(RequestPort).

    server_loop(RequestPort) :-
	repeat,
	    mps_receive(RequestPort, request(Goal, ReplyPort)),
	    once(Goal),
	    mps_send(ReplyPort, Goal),
	fail.

% code on client

    client_init(NsrvHost, RequestPort-ReplyPort) :-
	mps_init(NsrvHost),
	mps_port_allocate(true/0, ReplyPort),
	repeat,
	    mps_port_lookup("SampleServer", "RunGoal", RequestPort),
	!.

    remote_once(RequestPort-ReplyPort, Goal) :-
	mps_send(RequestPort, request(Goal, ReplyPort)),
	repeat,
	    mps_receive(ReplyPort, Reply),
	!,
	Goal = Reply.

% Sample session (client side):

    [eclipse 1]:  [client].
    client.pl  compiled traceable 624 bytes in 0.00 seconds
    yes.
    [eclipse 2]: client_init(breeze, Ports),
                 remote_once(Ports, X is 3+4).

    Ports = 794820612 - 364511236
    X = 7
    yes.



See Also

mps_init / 1, mps_ping / 1, mps_exit / 0, mps_port_register / 4, mps_port_lookup / 3, mps_port_deregister / 3, mps_port_allocate / 2, mps_port_deallocate / 1, mps_receive / 2