Information Technology Reference
In-Depth Information
portmap
daemon
1. Register Service
2. Find Server
server
client
3. Call remote service
4. Receive Response
Figure 2.4.
Sun ONC runtime binding.
if ((message = getdate_1(NULL, cl)) == NULL) {
clnt_perror(cl, server);
exit(1);
}
printf( "Server Date: %s\n" , ∗message);
clnt_destroy(cl);
and our server implementation:
char ∗∗ getdate_1_svc(void ∗v, struct svc_req ∗svc) {
time_t now = time(NULL);
static char ∗date;
date = ctime(&now);
return (&date);
}
Note that both the client and server implementation code is required to ad-
here to the ONC specific framework and programming conventions. For example,
in the server implementation, the value that is returned to the client is required
to be static and the function signature is required to use the framework specific
structure svc_req and to have the program's version number appended. For the
client implementation, the client is required to call the ONC framework directly,
as illustrated by the clnt_create function call in our example. However, for the
server code no protocol specific code is required.
ONC servers advertise their presence in the portmap service so that clients
may find them. At runtime clients bind to the portmap server, which provides the
address of the server to clients as illustrated in Figure 2.4. Clients then connect
directly to the server.
Search WWH ::




Custom Search