| clearthink@cavtel.net 2005-09-29, 6:00 pm |
| I have an existing multi-threaded program.
I want to add RPC. The program needs to act
as a client calling remote methods and act
as a server accepting remote calls. Having
the program act as a client is straightforward.
I am confused on it acting as a server which
plays nice with the rest of the code.
I see the code in XXXX_svr.c as generated by rpcgen.
(on my linux box, it consists of calls
to create and register a UDP and
TCP service finally calling srv_run()
which is the main receive-dispatch
loop)
But ...
The last line of the main method in my program
(by which some other 13 threads have been created
and are running) calls an infinite input-process-print
loop. It's supports a legacy way to
get diagnostics through the keyboard.
So how can I insert the call to src_run()? For if
I do, it will not return and the keyboard I/O loop
above is disabled. And the otherway around the
keyboard loop will not return so srv_run() does
not start.
Q1.
Must I put that code into main? Or
can I spin off a new thread and put
that code in there? If I locate the
srv_run() in a thread, how do I get
the thread to wake up when I/O comes
and how to I stop it from pinging
the CPU?
How do people do this?
|