mps_receive/2 gets the next incoming message from the specified port. Ports queue incoming messages, and mps_receive/2 takes them out one at a time. If fails if the queue is empty.
The port must have been allocated previously in the same process, using mps_port_allocate/2..
% 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.