Go to main content

ONC+ RPC Developer's Guide

Exit Print View

Updated: March 2019
 
 

MT Client Overview

In a multithread client program, a thread can be created to issue each RPC request. When multiple threads share the same client handle, only one thread at a time is able to make an RPC request. All other threads wait until the outstanding request is complete. On the other hand, when multiple threads make RPC requests using different client handles, the requests are carried out concurrently. Two Client Threads Using Different Client Handles (Real Time) illustrates a possible timing of a multithreaded client implementation consisting of two client threads using different client handles.

The following figure shows the client side implementation of a multithreaded rstat program. The client program creates a thread for each host. Each thread creates its own client handle and makes various RPC calls to the given host. Because the client threads are using different handles to make the RPC calls, they can carry out the RPC calls concurrently.

Figure 5  Two Client Threads Using Different Client Handles (Real Time)

image:Graphic shows two client threads using different client             handles


Note -  You must link in the thread library when writing any RPC multithreaded-safe application. The thread library must be the last named library on the link line. To link this properly, specify the –lthread option in the compile command.

Compile the program in the code example by typing cc rstat.c -lnsl -lthread.