Specifications
Remote Procedure Call Programming Guide Page 31
5.3. Callback Procedures
Occasionally, it is useful to have a server become a client, and make an RPC call back to the process which
is its client. An example is remote debugging, where the client is a window system program, and the server
is a debugger running on the remote machine. Most of the time, the user clicks a mouse button at the
debugging window, which converts this to a debugger command, and then makes an RPC call to the server
(where the debugger is actually running), telling it to execute that command. However, when the debugger
hits a breakpoint, the roles are reversed, and the debugger wants to make an rpc call to the window pro-
gram, so that it can inform the user that a breakpoint has been reached.
In order to do an RPC callback, you need a program number to make the RPC call on. Since this will be a
dynamically generated program number, it should be in the transient range, 0x40000000 - 0x5fffffff. The
routine gettransient() returns a valid program number in the transient range, and registers it with the
portmapper. It only talks to the portmapper running on the same machine as the gettransient() routine
itself. The call to pmap_set() is a test and set operation, in that it indivisibly tests whether a program num-
ber has already been registered, and if it has not, then reserves it. On return, the sockp argument will con-
tain a socket that can be used as the argument to an svcudp_create() or svctcp_create() call.