Writing RPC Server code

Vipin Samar vipin at eng.sun.com
Tue Nov 20 04:22:37 AEST 1990


G.Eustace at massey.ac.nz (Glen Eustace) writes:

>What I thought was the correct thing to do, on the server side, was
>to create a new instance of the daemon when the clntudp_create is
>executed and let that client/server pair talk to each other until the
>clnt_destroy at which time the server terminates.  My thinking was
>that additional client/server pairs would be created as needed.
>I can't seem to work out how one can actually do the above.

As far as the client is concerned, it should not care whether a new
instance is created or whether the same old server can serve your
request.  The server created through svcudp_create() [or done via
rpcgen] answers your requests itself.  It treats each request as
an independent one.  However, if you were to use TCP [svctcp_create()],
the server creates a connection [in the same process] and then the
client and the server can merrily go along exchanging messages.  When
the client dies [clnt_destroy], the server is notified and it cleans up.
You, as a programmer, need not do anything special on either ends.
Does this help?

>If it is not the correct way to do things how does one
>prevent a new client from having to wait for an earlier one to
>complete its processing?

The current implementations are single threaded - so while a particular
request is being served, the server will not entertain other requests.
However, one can interleave requests from other clients.  In the case
of TCP, even though different connections have been set up with different
clients, their requests are still serialized.

>My line of thought was based on the TCP
>idea i.e. telnet, where a connection is made on a well known port and
>then the server and client shift their conversation to another thus
>making the well known port available for a new connection.

In case of ftp, telnet, etc., the server forks for every new request
and this is different from vanilla ONC-RPC implementation.  One can
however, put in enough smarts into svc_tcp.c code
to achieve the above.  You should be able to get hold of all the
source code - the code is freely licensable.

>-- 
>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>Glen Eustace, Software Manager, Computer Centre, Massey University,

vipin

Disclaimer: I speak for no one but myself.
--
vipin at Eng.sun.com || sun!Eng!vipin



More information about the Comp.unix.questions mailing list