{
    "mode": "info",
    "parameter": "rpc_clnt_create",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/rpc_clnt_create/json",
    "generated": "2026-07-05T13:02:58Z",
    "synopsis": "#include <rpc/rpc.h>\nboolt\nclntcontrol(CLIENT *clnt, const uint req, char *info);\nCLIENT *\nclntcreate(const char * host, const rpcprogt prognum,\nconst rpcverst versnum, const char *nettype);\nCLIENT *\nclntcreatetimed(const char * host, const rpcprogt prognum,\nconst rpcverst versnum, const char *nettype,\nconst struct timeval *timeout);\nCLIENT *\nclntcreatevers(const char * host, const rpcprogt prognum,\nrpcverst *versoutp, const rpcverst verslow,\nconst rpcverst vershigh, const char *nettype);\nCLIENT *\nclntcreateverstimed(const char * host, const rpcprogt prognum,\nrpcverst *versoutp, const rpcverst verslow,\nconst rpcverst vershigh, char *nettype,\nconst struct timeval *timeout);\nvoid\nclntdestroy(CLIENT *clnt);\nCLIENT *\nclntdgcreate(const int fildes, const struct netbuf *svcaddr,\nconst rpcprogt prognum, const rpcverst versnum, const uint sendsz,\nconst uint recvsz);\nvoid\nclntpcreateerror(const char *s);\nchar *\nclntspcreateerror(const char *s);\nCLIENT *\nclntrawcreate(const rpcprogt prognum, const rpcverst versnum);\nCLIENT *\nclnttlicreate(const int fildes, const struct netconfig *netconf,\nconst struct netbuf *svcaddr, const rpcprogt prognum,\nconst rpcverst versnum, const uint sendsz, const uint recvsz);\nCLIENT *\nclnttpcreate(const char * host, const rpcprogt prognum,\nconst rpcverst versnum, const struct netconfig *netconf);\nCLIENT *\nclnttpcreatetimed(const char * host, const rpcprogt prognum,\nconst rpcverst versnum, const struct netconfig *netconf,\nconst struct timeval *timeout);\nCLIENT *\nclntvccreate(const int fildes, const struct netbuf *svcaddr,\nconst rpcprogt prognum, const rpcverst versnum, uint sendsz,\nuint recvsz);",
    "sections": {
        "NAME": {
            "content": "rpcclntcreate, clntcontrol, clntcreate, clntcreatetimed,\nclntcreatevers, clntcreateverstimed, clntdestroy, clntdgcreate,\nclntpcreateerror, clntrawcreate, clntspcreateerror, clnttlicreate,\nclnttpcreate, clnttpcreatetimed, clntvccreate, rpccreateerr --\nlibrary routines for dealing with creation and manipulation of CLIENT\nhandles\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "#include <rpc/rpc.h>\n\nboolt\nclntcontrol(CLIENT *clnt, const uint req, char *info);\n\nCLIENT *\nclntcreate(const char * host, const rpcprogt prognum,\nconst rpcverst versnum, const char *nettype);\n\nCLIENT *\nclntcreatetimed(const char * host, const rpcprogt prognum,\nconst rpcverst versnum, const char *nettype,\nconst struct timeval *timeout);\n\nCLIENT *\nclntcreatevers(const char * host, const rpcprogt prognum,\nrpcverst *versoutp, const rpcverst verslow,\nconst rpcverst vershigh, const char *nettype);\n\nCLIENT *\nclntcreateverstimed(const char * host, const rpcprogt prognum,\nrpcverst *versoutp, const rpcverst verslow,\nconst rpcverst vershigh, char *nettype,\nconst struct timeval *timeout);\n\nvoid\nclntdestroy(CLIENT *clnt);\n\nCLIENT *\nclntdgcreate(const int fildes, const struct netbuf *svcaddr,\nconst rpcprogt prognum, const rpcverst versnum, const uint sendsz,\nconst uint recvsz);\n\nvoid\nclntpcreateerror(const char *s);\n\nchar *\nclntspcreateerror(const char *s);\n\nCLIENT *\nclntrawcreate(const rpcprogt prognum, const rpcverst versnum);\n\nCLIENT *\nclnttlicreate(const int fildes, const struct netconfig *netconf,\nconst struct netbuf *svcaddr, const rpcprogt prognum,\nconst rpcverst versnum, const uint sendsz, const uint recvsz);\n\nCLIENT *\nclnttpcreate(const char * host, const rpcprogt prognum,\nconst rpcverst versnum, const struct netconfig *netconf);\n\nCLIENT *\nclnttpcreatetimed(const char * host, const rpcprogt prognum,\nconst rpcverst versnum, const struct netconfig *netconf,\nconst struct timeval *timeout);\n\nCLIENT *\nclntvccreate(const int fildes, const struct netbuf *svcaddr,\nconst rpcprogt prognum, const rpcverst versnum, uint sendsz,\nuint recvsz);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "RPC library routines allow C language programs to make procedure calls on\nother machines across the network.  First a CLIENT handle is created and\nthen the client calls a procedure to send a request to the server.  On\nreceipt of the request, the server calls a dispatch routine to perform\nthe requested service, and then sends a reply.\n",
            "subsections": []
        },
        "Routines": {
            "content": "clntcontrol()\nA function macro to change or retrieve various information about\na client object.  The req argument indicates the type of opera-\ntion, and info is a pointer to the information.  For both con-\nnectionless and connection-oriented transports, the supported\nvalues of req and their argument types and what they do are:\n\nCLSETTIMEOUT      struct timeval *    set total timeout\nCLGETTIMEOUT      struct timeval *    get total timeout\n\nNote: if you set the timeout using clntcontrol(), the timeout\nargument passed by clntcall() is ignored in all subsequent\ncalls.\n\nNote: If you set the timeout value to 0, clntcontrol() immedi-\nately returns an error (RPCTIMEDOUT).  Set the timeout argument\nto 0 for batching calls.\n\nCLGETSVCADDR     struct netbuf *     get servers address\nCLGETFD           int *               get fd from handle\nCLSETFDCLOSE     void                close fd on destroy\nCLSETFDNCLOSE    void                don't close fd on destroy\nCLGETVERS         uint32t *         get RPC program version\nCLSETVERS         uint32t *         set RPC program version\nCLGETXID          uint32t *         get XID of previous call\nCLSETXID          uint32t *         set XID of next call\n\nThe following operations are valid for connectionless transports\nonly:\n\nCLSETRETRYTIMEOUT    struct timeval *    set the retry timeout\nCLGETRETRYTIMEOUT    struct timeval *    get the retry timeout\nCLSETCONNECT          int *               use connect(2)\n\nThe retry timeout is the time that RPC waits for the server to\nreply before retransmitting the request.  The clntcontrol()\nfunction returns TRUE on success and FALSE on failure.\n\nclntcreate()\nGeneric client creation routine for program prognum and version\nversnum.  The host argument identifies the name of the remote\nhost where the server is located.  The nettype argument indi-\ncates the class of transport protocol to use.  The transports\nare tried in left to right order in NETPATH environment variable\nor in top to bottom order in the netconfig database.  The\nclntcreate() function tries all the transports of the nettype\nclass available from the NETPATH environment variable and the\nnetconfig database, and chooses the first successful one.  A de-\nfault timeout is set and can be modified using clntcontrol().\nThis routine returns NULL if it fails.  The clntpcreateerror()\nroutine can be used to print the reason for failure.\n\nNote: clntcreate() returns a valid client handle even if the\nparticular version number supplied to clntcreate() is not reg-\nistered with the rpcbind(8) service.  This mismatch will be dis-\ncovered by a clntcall() later (see rpcclntcalls(3)).\n\nclntcreatetimed()\nGeneric client creation routine which is similar to\nclntcreate() but which also has the additional argument timeout\nthat specifies the maximum amount of time allowed for each\ntransport class tried.  In all other respects, the\nclntcreatetimed() call behaves exactly like the clntcreate()\ncall.\n\nclntcreatevers()\nGeneric client creation routine which is similar to\nclntcreate() but which also checks for the version availabil-\nity.  The host argument identifies the name of the remote host\nwhere the server is located.  The nettype argument indicates the\nclass transport protocols to be used.  If the routine is suc-\ncessful it returns a client handle created for the highest ver-\nsion between verslow and vershigh that is supported by the\nserver.  The versoutp argument is set to this value.  That is,\nafter a successful return verslow <= *versoutp <= vershigh.\nIf no version between verslow and vershigh is supported by the\nserver then the routine fails and returns NULL.  A default time-\nout is set and can be modified using clntcontrol().  This rou-\ntine returns NULL if it fails.  The clntpcreateerror() routine\ncan be used to print the reason for failure.  Note:\nclntcreate() returns a valid client handle even if the particu-\nlar version number supplied to clntcreate() is not registered\nwith the rpcbind(8) service.  This mismatch will be discovered\nby a clntcall() later (see rpcclntcalls(3)).  However,\nclntcreatevers() does this for you and returns a valid handle\nonly if a version within the range supplied is supported by the\nserver.\n\nclntcreateverstimed()\nGeneric client creation routine which is similar to\nclntcreatevers() but which also has the additional argument\ntimeout that specifies the maximum amount of time allowed for\neach transport class tried.  In all other respects, the\nclntcreateverstimed() call behaves exactly like the\nclntcreatevers() call.\n\nclntdestroy()\nA function macro that destroys the client's RPC handle.  De-\nstruction usually involves deallocation of private data struc-\ntures, including clnt itself.  Use of clnt is undefined after\ncalling clntdestroy().  If the RPC library opened the associ-\nated file descriptor, or CLSETFDCLOSE was set using\nclntcontrol(), the file descriptor will be closed.  The caller\nshould call authdestroy(clnt->clauth) (before calling\nclntdestroy()) to destroy the associated AUTH structure (see\nrpcclntauth(3)).\n\nclntdgcreate()\nThis routine creates an RPC client for the remote program\nprognum and version versnum; the client uses a connectionless\ntransport.  The remote program is located at address svcaddr.\nThe fildes argument is an open and bound file descriptor.  This\nroutine will resend the call message in intervals of 15 seconds\nuntil a response is received or until the call times out.  The\ntotal time for the call to time out is specified by clntcall()\n(see clntcall() in rpcclntcalls(3)).  The retry time out and\nthe total time out periods can be changed using clntcontrol().\nThe user may set the size of the send and receive buffers with\nthe sendsz and recvsz arguments; values of 0 choose suitable de-\nfaults.  This routine returns NULL if it fails.\n\nclntpcreateerror()\nPrint a message to standard error indicating why a client RPC\nhandle could not be created.  The message is prepended with the\nstring s and a colon, and appended with a newline.\n\nclntspcreateerror()\nLike clntpcreateerror(), except that it returns a string in-\nstead of printing to the standard error.  A newline is not ap-\npended to the message in this case.  Warning: returns a pointer\nto a buffer that is overwritten on each call.\n\nclntrawcreate()\nThis routine creates an RPC client handle for the remote program\nprognum and version versnum.  The transport used to pass mes-\nsages to the service is a buffer within the process's address\nspace, so the corresponding RPC server should live in the same\naddress space; (see svcrawcreate() in rpcsvccreate(3)).\nThis allows simulation of RPC and measurement of RPC overheads,\nsuch as round trip times, without any kernel or networking in-\nterference.  This routine returns NULL if it fails.  The\nclntrawcreate() function should be called after\nsvcrawcreate().\n\nclnttlicreate()\nThis routine creates an RPC client handle for the remote program\nprognum and version versnum.  The remote program is located at\naddress svcaddr.  If svcaddr is NULL and it is connection-ori-\nented, it is assumed that the file descriptor is connected.  For\nconnectionless transports, if svcaddr is NULL, RPCUNKNOWNADDR\nerror is set.  The fildes argument is a file descriptor which\nmay be open, bound and connected.  If it is RPCANYFD, it opens\na file descriptor on the transport specified by netconf.  If\nfildes is RPCANYFD and netconf is NULL, a RPCUNKNOWNPROTO er-\nror is set.  If fildes is unbound, then it will attempt to bind\nthe descriptor.  The user may specify the size of the buffers\nwith the sendsz and recvsz arguments; values of 0 choose suit-\nable defaults.  Depending upon the type of the transport (con-\nnection-oriented or connectionless), clnttlicreate() calls ap-\npropriate client creation routines.  This routine returns NULL\nif it fails.  The clntpcreateerror() routine can be used to\nprint the reason for failure.  The remote rpcbind service (see\nrpcbind(8)) is not consulted for the address of the remote ser-\nvice.\n\nclnttpcreate()\nLike clntcreate() except clnttpcreate() tries only one trans-\nport specified through netconf.  The clnttpcreate() function\ncreates a client handle for the program prognum, the version\nversnum, and for the transport specified by netconf.  Default\noptions are set, which can be changed using clntcontrol()\ncalls.  The remote rpcbind service on the host host is consulted\nfor the address of the remote service.  This routine returns\nNULL if it fails.  The clntpcreateerror() routine can be used\nto print the reason for failure.\n\nclnttpcreatetimed()\nLike clnttpcreate() except clnttpcreatetimed() has the ex-\ntra argument timeout which specifies the maximum time allowed\nfor the creation attempt to succeed.  In all other respects, the\nclnttpcreatetimed() call behaves exactly like the\nclnttpcreate() call.\n\nclntvccreate()\nThis routine creates an RPC client for the remote program\nprognum and version versnum; the client uses a connection-ori-\nented transport.  The remote program is located at address\nsvcaddr.  The fildes argument is an open and bound file descrip-\ntor.  The user may specify the size of the send and receive buf-\nfers with the sendsz and recvsz arguments; values of 0 choose\nsuitable defaults.  This routine returns NULL if it fails.  The\naddress svcaddr should not be NULL and should point to the ac-\ntual address of the remote program.  The clntvccreate() func-\ntion does not consult the remote rpcbind service for this infor-\nmation.\n\nstruct rpccreateerr rpccreateerr;\nA global variable whose value is set by any RPC client handle\ncreation routine that fails.  It is used by the routine\nclntpcreateerror() to print the reason for the failure.\n",
            "subsections": []
        },
        "AVAILABILITY": {
            "content": "These functions are part of libtirpc.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "rpc(3), rpcclntauth(3), rpcclntcalls(3), rpcbind(8)\n\nBSD                               May 7, 1993                              BSD",
            "subsections": []
        }
    },
    "summary": "rpcclntcreate, clntcontrol, clntcreate, clntcreatetimed, clntcreatevers, clntcreateverstimed, clntdestroy, clntdgcreate, clntpcreateerror, clntrawcreate, clntspcreateerror, clnttlicreate, clnttpcreate, clnttpcreatetimed, clntvccreate, rpccreateerr -- library routines for dealing with creation and manipulation of CLIENT handles",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "rpc",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/rpc/3/json"
        },
        {
            "name": "rpcclntauth",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/rpcclntauth/3/json"
        },
        {
            "name": "rpcclntcalls",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/rpcclntcalls/3/json"
        },
        {
            "name": "rpcbind",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/rpcbind/8/json"
        }
    ]
}