---
name: "clnt_raw_create"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/clnt_control"
---

# clnt\_raw\_create(3)

library routines for dealing with creation and manipulation of CLIENT handles

Part of [clnt\_control(3)](/clnt_control/3.md).

## NAME

**rpc\_clnt\_create**, **clnt\_control**, **clnt\_create**, **clnt\_create\_timed**, **clnt\_create\_vers**, **clnt\_create\_vers\_timed**, **clnt\_destroy**, **clnt\_dg\_create**, **clnt\_pcreateerror**, **clnt\_raw\_create**, **clnt\_spcreateerror**, **clnt\_tli\_create**, **clnt\_tp\_create**, **clnt\_tp\_create\_timed**, **clnt\_vc\_create**, **rpc\_createerr** – library routines for dealing with creation and manipulation of *CLIENT* handles

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

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

*bool\_t*\

**clnt\_control**(*CLIENT \*clnt*, *const u\_int req*, *char \*info*);

*CLIENT \**\

**clnt\_create**(*const char \* host*, *const rpcprog\_t prognum*, *const rpcvers\_t versnum*, *const char \*nettype*);

*CLIENT \**\

**clnt\_create\_timed**(*const char \* host*, *const rpcprog\_t prognum*, *const rpcvers\_t versnum*, *const char \*nettype*, *const struct timeval \*timeout*);

*CLIENT \**\

**clnt\_create\_vers**(*const char \* host*, *const rpcprog\_t prognum*, *rpcvers\_t \*vers\_outp*, *const rpcvers\_t vers\_low*, *const rpcvers\_t vers\_high*, *const char \*nettype*);

*CLIENT \**\

**clnt\_create\_vers\_timed**(*const char \* host*, *const rpcprog\_t prognum*, *rpcvers\_t \*vers\_outp*, *const rpcvers\_t vers\_low*, *const rpcvers\_t vers\_high*, *const char \*nettype*, *const struct timeval \*timeout*);

*void*\

**clnt\_destroy**(*CLIENT \*clnt*);

*CLIENT \**\

**clnt\_dg\_create**(*const int fildes*, *const struct netbuf \*svcaddr*, *const rpcprog\_t prognum*, *const rpcvers\_t versnum*, *const u\_int sendsz*, *const u\_int recvsz*);

*void*\

**clnt\_pcreateerror**(*const char \*s*);

*char \**\

**clnt\_spcreateerror**(*const char \*s*);

*CLIENT \**\

**clnt\_raw\_create**(*const rpcprog\_t prognum*, *const rpcvers\_t versnum*);

*CLIENT \**\

**clnt\_tli\_create**(*const int fildes*, *const struct netconfig \*netconf*, *struct netbuf \*svcaddr*, *const rpcprog\_t prognum*, *const rpcvers\_t versnum*, *const u\_int sendsz*, *const u\_int recvsz*);

*CLIENT \**\

**clnt\_tp\_create**(*const char \* host*, *const rpcprog\_t prognum*, *const rpcvers\_t versnum*, *const struct netconfig \*netconf*);

*CLIENT \**\

**clnt\_tp\_create\_timed**(*const char \* host*, *const rpcprog\_t prognum*, *const rpcvers\_t versnum*, *const struct netconfig \*netconf*, *const struct timeval \*timeout*);

*CLIENT \**\

**clnt\_vc\_create**(*const int fildes*, *const struct netbuf \*svcaddr*, *const rpcprog\_t prognum*, *const rpcvers\_t versnum*, *u\_int sendsz*, *u\_int recvsz*);

## DESCRIPTION

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

## Routines

- **clnt\_control**()

  A function macro to change or retrieve various information about a client object. The *req* argument indicates the type of operation, and *info* is a pointer to the information. For both connectionless and connection-oriented transports, the supported values of *req* and their argument types and what they do are:

  | | | |
  | --- | --- | --- |
  | CLSET\_TIMEOUT | struct timeval \* | set total timeout |
  | CLGET\_TIMEOUT | struct timeval \* | get total timeout |

- **clnt\_create**()

  Generic client creation routine for program *prognum* and version *versnum*. The *host* argument identifies the name of the remote host where the server is located. The *nettype* argument indicates the class of transport protocol to use. The transports are tried in left to right order in NETPATH environment variable or in top to bottom order in the netconfig database. The **clnt\_create**() function tries all the transports of the *nettype* class available from the NETPATH environment variable and the netconfig database, and chooses the first successful one. A default timeout is set and can be modified using **clnt\_control**(). This routine returns NULL if it fails. The **clnt\_pcreateerror**() routine can be used to print the reason for failure.

  Note: **clnt\_create**() returns a valid client handle even if the particular version number supplied to **clnt\_create**() is not registered with the [rpcbind(8)](/rpcbind/8.md) service. This mismatch will be discovered by a **clnt\_call**() later (see [rpc\_clnt\_calls(3)](/rpc_clnt_calls/3.md)).

- **clnt\_create\_timed**()

  Generic client creation routine which is similar to **clnt\_create**() but which also has the additional argument *timeout* that specifies the maximum amount of time allowed for each transport class tried. In all other respects, the **clnt\_create\_timed**() call behaves exactly like the **clnt\_create**() call.

- **clnt\_create\_vers**()

  Generic client creation routine which is similar to **clnt\_create**() but which also checks for the version availability. The *host* argument identifies the name of the remote host where the server is located. The *nettype* argument indicates the class transport protocols to be used. If the routine is successful it returns a client handle created for the highest version between *vers\_low* and *vers\_high* that is supported by the server. The *vers\_outp* argument is set to this value. That is, after a successful return *vers\_low* \<= *\*vers\_outp* \<= *vers\_high*. If no version between *vers\_low* and *vers\_high* is supported by the server then the routine fails and returns NULL. A default timeout is set and can be modified using **clnt\_control**(). This routine returns NULL if it fails. The **clnt\_pcreateerror**() routine can be used to print the reason for failure. Note: **clnt\_create**() returns a valid client handle even if the particular version number supplied to **clnt\_create**() is not registered with the [rpcbind(8)](/rpcbind/8.md) service. This mismatch will be discovered by a **clnt\_call**() later (see [rpc\_clnt\_calls(3)](/rpc_clnt_calls/3.md)). However, **clnt\_create\_vers**() does this for you and returns a valid handle only if a version within the range supplied is supported by the server.

- **clnt\_create\_vers\_timed**()

  Generic client creation routine which is similar to **clnt\_create\_vers**() but which also has the additional argument *timeout* that specifies the maximum amount of time allowed for each transport class tried. In all other respects, the **clnt\_create\_vers\_timed**() call behaves exactly like the **clnt\_create\_vers**() call.

- **clnt\_destroy**()

  A function macro that destroys the client's RPC handle. Destruction usually involves deallocation of private data structures, including *clnt* itself. Use of *clnt* is undefined after calling **clnt\_destroy**(). If the RPC library opened the associated file descriptor, or CLSET\_FD\_CLOSE was set using **clnt\_control**(), the file descriptor will be closed. The caller should call **auth\_destroy**(*clnt-\>cl\_auth*) (before calling **clnt\_destroy**()) to destroy the associated *AUTH* structure (see [rpc\_clnt\_auth(3)](/rpc_clnt_auth/3.md)).

- **clnt\_dg\_create**()

  This routine creates an RPC client for the remote program *prognum* and version *versnum*; the client uses a connectionless transport. The remote program is located at address *svcaddr*. The *fildes* argument is an open and bound file descriptor. This routine will resend the call message in intervals of 15 seconds until a response is received or until the call times out. The total time for the call to time out is specified by **clnt\_call**() (see **clnt\_call**() in [rpc\_clnt\_calls(3)](/rpc_clnt_calls/3.md)). The retry time out and the total time out periods can be changed using **clnt\_control**(). The user may set the size of the send and receive buffers with the *sendsz* and *recvsz* arguments; values of 0 choose suitable defaults. This routine returns NULL if it fails.

- **clnt\_pcreateerror**()

  Print a message to standard error indicating why a client RPC handle could not be created. The message is prepended with the string *s* and a colon, and appended with a newline.

- **clnt\_spcreateerror**()

  Like **clnt\_pcreateerror**(), except that it returns a string instead of printing to the standard error. A newline is not appended to the message in this case. Warning: returns a pointer to a buffer that is overwritten on each call.

- **clnt\_raw\_create**()

  This routine creates an RPC client handle for the remote program *prognum* and version *versnum*. The transport used to pass messages to the service is a buffer within the process's address space, so the corresponding RPC server should live in the same address space; (see **svc\_raw\_create**() in [rpc\_svc\_create(3)](/rpc_svc_create/3.md)). This allows simulation of RPC and measurement of RPC overheads, such as round trip times, without any kernel or networking interference. This routine returns NULL if it fails. The **clnt\_raw\_create**() function should be called after **svc\_raw\_create**().

- **clnt\_tli\_create**()

  This routine creates an RPC client handle for the remote program *prognum* and version *versnum*. The remote program is located at address *svcaddr*. If *svcaddr* is NULL and it is connection-oriented, it is assumed that the file descriptor is connected. For connectionless transports, if *svcaddr* is NULL, RPC\_UNKNOWNADDR error is set. The *fildes* argument is a file descriptor which may be open, bound and connected. If it is RPC\_ANYFD, it opens a file descriptor on the transport specified by *netconf*. If *fildes* is RPC\_ANYFD and *netconf* is NULL, a RPC\_UNKNOWNPROTO error is set. If *fildes* is unbound, then it will attempt to bind the descriptor. The user may specify the size of the buffers with the *sendsz* and *recvsz* arguments; values of 0 choose suitable defaults. Depending upon the type of the transport (connection-oriented or connectionless), **clnt\_tli\_create**() calls appropriate client creation routines. This routine returns NULL if it fails. The **clnt\_pcreateerror**() routine can be used to print the reason for failure. The remote rpcbind service (see [rpcbind(8)](/rpcbind/8.md)) is not consulted for the address of the remote service.

- **clnt\_tp\_create**()

  Like **clnt\_create**() except **clnt\_tp\_create**() tries only one transport specified through *netconf*. The **clnt\_tp\_create**() function creates a client handle for the program *prognum*, the version *versnum*, and for the transport specified by *netconf*. Default options are set, which can be changed using **clnt\_control**() calls. The remote rpcbind service on the host *host* is consulted for the address of the remote service. This routine returns NULL if it fails. The **clnt\_pcreateerror**() routine can be used to print the reason for failure.

- **clnt\_tp\_create\_timed**()

  Like **clnt\_tp\_create**() except **clnt\_tp\_create\_timed**() has the extra argument *timeout* which specifies the maximum time allowed for the creation attempt to succeed. In all other respects, the **clnt\_tp\_create\_timed**() call behaves exactly like the **clnt\_tp\_create**() call.

- **clnt\_vc\_create**()

  This routine creates an RPC client for the remote program *prognum* and version *versnum*; the client uses a connection-oriented transport. The remote program is located at address *svcaddr*. The *fildes* argument is an open and bound file descriptor. The user may specify the size of the send and receive buffers with the *sendsz* and *recvsz* arguments; values of 0 choose suitable defaults. This routine returns NULL if it fails. The address *svcaddr* should not be NULL and should point to the actual address of the remote program. The **clnt\_vc\_create**() function does not consult the remote rpcbind service for this information.

-

  *struct rpc\_createerr* *rpc\_createerr*; A global variable whose value is set by any RPC client handle creation routine that fails. It is used by the routine **clnt\_pcreateerror**() to print the reason for the failure.

## SEE ALSO

[rpc(3)](/rpc/3.md), [rpc\_clnt\_auth(3)](/rpc_clnt_auth/3.md), [rpc\_clnt\_calls(3)](/rpc_clnt_calls/3.md), [rpcbind(8)](/rpcbind/8.md)
