/***
@author  8boomgaa & 8njemz
@date	 2010/02/25 15:24
@descr
*/

:- consult('servers_little_helpers.pl').
:- consult('server.pl').
:- dynamic(response/2).
/**
@form broadcast()
@constraints
@descr
*/


/**
@form query(+ID, +Pred) 
@constraints
@descr
*/
query(ID, Pred, Output):-
%	fork(child),
	term_to_atom(Pred,Atom),
	id2socket(Recv,Sock),
	send(Sock, append, Atom),
	wait_for_reply(Recv,Output),
	retractall(response(_,_)).

% Output from client
wait_for_reply(ID,Output) :-
	fork(child),
	wait(child,exited(_)),
	assert(pending(ID)),
	repeat,
	response(ID,Output).

%event(+ID, +PredName, +Output)
% Output is a List 


















