---
name: "rpc_clnt_calls"
section: "3t"
platform: "linux"
package: "libtirpc"
version: "1.3.8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/rpc_clnt_calls/3t"
---

# rpc\_clnt\_calls(3t)

library routines for client side calls

## NAME

**rpc\_clnt\_calls**, **clnt\_call**, **clnt\_freeres**, **clnt\_geterr**, **clnt\_perrno**, **clnt\_perror**, **clnt\_sperrno**, **clnt\_sperror**, **rpc\_broadcast**, **rpc\_broadcast\_exp**, **rpc\_call** – library routines for client side calls

## SYNOPSIS

**#include \<rpc/rpc.h\>**

*enum clnt\_stat*\

**clnt\_call**(*CLIENT \*clnt*, *const rpcproc\_t procnum*, *const xdrproc\_t inproc*, *const caddr\_t in*, *const xdrproc\_t outproc*, *caddr\_t out*, *const struct timeval tout*);

*bool\_t*\

**clnt\_freeres**(*CLIENT \*clnt*, *const xdrproc\_t outproc*, *caddr\_t out*);

*void*\

**clnt\_geterr**(*const CLIENT \* clnt*, *struct rpc\_err \* errp*);

*void*\

**clnt\_perrno**(*const enum clnt\_stat stat*);

*void*\

**clnt\_perror**(*CLIENT \*clnt*, *const char \*s*);

*char \**\

**clnt\_sperrno**(*const enum clnt\_stat stat*);

*char \**\

**clnt\_sperror**(*CLIENT \*clnt*, *const char \* s*);

*enum clnt\_stat*\

**rpc\_broadcast**(*const rpcprog\_t prognum*, *const rpcvers\_t versnum*, *const rpcproc\_t procnum*, *const xdrproc\_t inproc*, *const caddr\_t in*, *const xdrproc\_t outproc*, *caddr\_t out*, *const resultproc\_t eachresult*, *const char \*nettype*);

*enum clnt\_stat*\

**rpc\_broadcast\_exp**(*const rpcprog\_t prognum*, *const rpcvers\_t versnum*, *const rpcproc\_t procnum*, *const xdrproc\_t xargs*, *caddr\_t argsp*, *const xdrproc\_t xresults*, *caddr\_t resultsp*, *const resultproc\_t eachresult*, *const int inittime*, *const int waittime*, *const char \* nettype*);

*enum clnt\_stat*\

**rpc\_call**(*const char \*host*, *const rpcprog\_t prognum*, *const rpcvers\_t versnum*, *const rpcproc\_t procnum*, *const xdrproc\_t inproc*, *const char \*in*, *const xdrproc\_t outproc*, *char \*out*, *const char \*nettype*);

## DESCRIPTION

RPC library routines allow C language programs to make procedure calls on other machines across the network. First, the client calls a procedure to send a request to the server. Upon receipt of the request, the server calls a dispatch routine to perform the requested service, and then sends back a reply.

The **clnt\_call**(), **rpc\_call**(), and **rpc\_broadcast**() routines handle the client side of the procedure call. The remaining routines deal with error handling in the case of errors.

Some of the routines take a *CLIENT* handle as one of the arguments. A *CLIENT* handle can be created by an RPC creation routine such as **clnt\_create**() (see [rpc\_clnt\_create(3)](/rpc_clnt_create/3.md)).

These routines are safe for use in multithreaded applications. *CLIENT* handles can be shared between threads, however in this implementation requests by different threads are serialized (that is, the first request will receive its results before the second request is sent).

## Routines

See [rpc(3)](/rpc/3.md) for the definition of the *CLIENT* data structure.

- **clnt\_call**()

  A function macro that calls the remote procedure *procnum* associated with the client handle, *clnt*, which is obtained with an RPC client creation routine such as **clnt\_create**() (see [rpc\_clnt\_create(3)](/rpc_clnt_create/3.md)). The *inproc* argument is the XDR function used to encode the procedure's arguments, and *outproc* is the XDR function used to decode the procedure's results; *in* is the address of the procedure's argument(s), and *out* is the address of where to place the result(s). The *tout* argument is the time allowed for results to be returned, which is overridden by a time-out set explicitly through **clnt\_control**(), see [rpc\_clnt\_create(3)](/rpc_clnt_create/3.md). If the remote call succeeds, the status returned is RPC\_SUCCESS, otherwise an appropriate status is returned.

- **clnt\_freeres**()

  A function macro that frees any data allocated by the RPC/XDR system when it decoded the results of an RPC call. The *out* argument is the address of the results, and *outproc* is the XDR routine describing the results. This routine returns 1 if the results were successfully freed, and 0 otherwise.

- **clnt\_geterr**()

  A function macro that copies the error structure out of the client handle to the structure at address *errp*.

- **clnt\_perrno**()

  Print a message to standard error corresponding to the condition indicated by *stat*. A newline is appended. Normally used after a procedure call fails for a routine for which a client handle is not needed, for instance **rpc\_call**().

- **clnt\_perror**()

  Print a message to the standard error indicating why an RPC call failed; *clnt* is the handle used to do the call. The message is prepended with string *s* and a colon. A newline is appended. Normally used after a remote procedure call fails for a routine which requires a client handle, for instance **clnt\_call**().

- **clnt\_sperrno**()

  Take the same arguments as **clnt\_perrno**(), but instead of sending a message to the standard error indicating why an RPC call failed, return a pointer to a string which contains the message. The **clnt\_sperrno**() function is normally used instead of **clnt\_perrno**() when the program does not have a standard error (as a program running as a server quite likely does not), or if the programmer does not want the message to be output with **printf**() (see [printf(3)](/printf/3.md)), or if a message format different than that supported by **clnt\_perrno**() is to be used. Note: unlike **clnt\_sperror**() and **clnt\_spcreateerror**() (see [rpc\_clnt\_create(3)](/rpc_clnt_create/3.md)), **clnt\_sperrno**() does not return pointer to static data so the result will not get overwritten on each call.

- **clnt\_sperror**()

  Like **clnt\_perror**(), except that (like **clnt\_sperrno**()) it returns a string instead of printing to standard error. However, **clnt\_sperror**() does not append a newline at the end of the message. Warning: returns pointer to a buffer that is overwritten on each call.

- **rpc\_broadcast**()

  Like **rpc\_call**(), except the call message is broadcast to all the connectionless transports specified by *nettype*. If *nettype* is NULL, it defaults to "netpath". Each time it receives a response, this routine calls **eachresult**(), whose form is: *bool\_t* **eachresult**(*caddr\_t out*, *const struct netbuf \* addr*, *const struct netconfig \* netconf*) where *out* is the same as *out* passed to **rpc\_broadcast**(), except that the remote procedure's output is decoded there; *addr* points to the address of the machine that sent the results, and *netconf* is the netconfig structure of the transport on which the remote server responded. If **eachresult**() returns 0, **rpc\_broadcast**() waits for more replies; otherwise it returns with appropriate status. Warning: broadcast file descriptors are limited in size to the maximum transfer size of that transport. For Ethernet, this value is 1500 bytes. The **rpc\_broadcast**() function uses AUTH\_SYS credentials by default (see [rpc\_clnt\_auth(3)](/rpc_clnt_auth/3.md)).

- **rpc\_broadcast\_exp**()

  Like **rpc\_broadcast**(), except that the initial timeout, *inittime* and the maximum timeout, *waittime* are specified in milliseconds. The *inittime* argument is the initial time that **rpc\_broadcast\_exp**() waits before resending the request. After the first resend, the re-transmission interval increases exponentially until it exceeds *waittime*.

- **rpc\_call**()

  Call the remote procedure associated with *prognum*, *versnum*, and *procnum* on the machine, *host*. The *inproc* argument is used to encode the procedure's arguments, and *outproc* is used to decode the procedure's results; *in* is the address of the procedure's argument(s), and *out* is the address of where to place the result(s). The *nettype* argument can be any of the values listed on [rpc(3)](/rpc/3.md). This routine returns RPC\_SUCCESS if it succeeds, or an appropriate status is returned. Use the **clnt\_perrno**() routine to translate failure status into error messages. Warning: **rpc\_call**() uses the first available transport belonging to the class *nettype*, on which it can create a connection. You do not have control of timeouts or authentication using this routine.

## AVAILABILITY

These functions are part of libtirpc.

## SEE ALSO

[printf(3)](/printf/3.md), [rpc(3)](/rpc/3.md), [rpc\_clnt\_auth(3)](/rpc_clnt_auth/3.md), [rpc\_clnt\_create(3)](/rpc_clnt_create/3.md)
