Multithreading
with Netbula RPC For Win32
Netbula RPC for
Win32 supports multithreading, this document describe the procedure
to build multithreaded (MT) RPC server and clients.
MT Server
There are two methods
to create MT servers: thread on connect and thread on call.
Thread on connect
By calling pw_set_mt_on_connect(1)
(with argument being 1) before svc{proto}_create(), the newly created
service becomes a MT server.
- UDP service
The UDP service will run in a separate thread of itself
- TCP service
A new dedicated thread will be created for each client upon connection
to the server, the thread exits when the client close the connection
with the server.
Thread on call
The option will
cause the server to create a new thread to handle an incoming RPC call,
this option is applied to individual procedures.
- ONC RPC
Enable this option by setting the mt_on_call field of the callInfo
structure to PWRPC_ONC_MT defined in powerrpc.h.
- PowerRPC
Enable this option by setting the mt_on_call field of the callInfo
structure to POWERRPC_THREADING defined in powerrpc.h.
MT Client
For ONC RPC, the
return result from is stored in a static variable, to make this variable
thread local, define the PWRPC_MT macro. One way to do this is
to add a line
%define
PWRPC_MT
in the *.x file.