18360efbdSAlfred Perlstein.\" @(#)rpc_clnt_calls.3n 1.30 93/08/31 SMI; from SVr4 28360efbdSAlfred Perlstein.\" Copyright 1989 AT&T 38360efbdSAlfred Perlstein.\" @(#)rpc_clnt_calls 1.4 89/07/20 SMI; 48360efbdSAlfred Perlstein.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. 58360efbdSAlfred Perlstein.\" $FreeBSD$ 68360efbdSAlfred Perlstein.Dd May 7, 1993 78360efbdSAlfred Perlstein.Dt RPC_CLNT_CALLS 3 88360efbdSAlfred Perlstein.Os 98360efbdSAlfred Perlstein.Sh NAME 108360efbdSAlfred Perlstein.Nm rpc_clnt_calls , 118360efbdSAlfred Perlstein.Nm clnt_call , 128360efbdSAlfred Perlstein.Nm clnt_freeres , 138360efbdSAlfred Perlstein.Nm clnt_geterr , 148360efbdSAlfred Perlstein.Nm clnt_perrno , 158360efbdSAlfred Perlstein.Nm clnt_perror , 168360efbdSAlfred Perlstein.Nm clnt_sperrno , 178360efbdSAlfred Perlstein.Nm clnt_sperror , 188360efbdSAlfred Perlstein.Nm rpc_broadcast , 198360efbdSAlfred Perlstein.Nm rpc_broadcast_exp , 208360efbdSAlfred Perlstein.Nm rpc_call 218360efbdSAlfred Perlstein.Nd library routines for client side calls 228360efbdSAlfred Perlstein.Sh LIBRARY 238360efbdSAlfred Perlstein.Lb libc 248360efbdSAlfred Perlstein.Sh SYNOPSIS 2532eef9aeSRuslan Ermilov.In rpc/rpc.h 268360efbdSAlfred Perlstein.Ft "enum clnt_stat" 278360efbdSAlfred Perlstein.Fn 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" 288360efbdSAlfred Perlstein.Ft bool_t 298360efbdSAlfred Perlstein.Fn clnt_freeres "CLIENT *clnt" "const xdrproc_t outproc" "caddr_t out" 308360efbdSAlfred Perlstein.Ft void 318360efbdSAlfred Perlstein.Fn clnt_geterr "const CLIENT * clnt" "struct rpc_err * errp" 328360efbdSAlfred Perlstein.Ft void 338360efbdSAlfred Perlstein.Fn clnt_perrno "const enum clnt_stat stat" 348360efbdSAlfred Perlstein.Ft void 35db7534cfSBruce Evans.Fn clnt_perror "CLIENT *clnt" "const char *s" 368360efbdSAlfred Perlstein.Ft "char *" 378360efbdSAlfred Perlstein.Fn clnt_sperrno "const enum clnt_stat stat" 388360efbdSAlfred Perlstein.Ft "char *" 39db7534cfSBruce Evans.Fn clnt_sperror "CLIENT *clnt" "const char * s" 408360efbdSAlfred Perlstein.Ft "enum clnt_stat" 418360efbdSAlfred Perlstein.Fo rpc_broadcast 428360efbdSAlfred Perlstein.Fa "const rpcprog_t prognum" "const rpcvers_t versnum" 438360efbdSAlfred Perlstein.Fa "const rpcproc_t procnum" "const xdrproc_t inproc" 448360efbdSAlfred Perlstein.Fa "const caddr_t in" "const xdrproc_t outproc" "caddr_t out" 458360efbdSAlfred Perlstein.Fa "const resultproc_t eachresult" "const char *nettype" 468360efbdSAlfred Perlstein.Fc 478360efbdSAlfred Perlstein.Ft "enum clnt_stat" 488360efbdSAlfred Perlstein.Fo rpc_broadcast_exp 49db7534cfSBruce Evans.Fa "const rpcprog_t prognum" "const rpcvers_t versnum" 508360efbdSAlfred Perlstein.Fa "const rpcproc_t procnum" "const xdrproc_t xargs" 518360efbdSAlfred Perlstein.Fa "caddr_t argsp" "const xdrproc_t xresults" 52db7534cfSBruce Evans.Fa "caddr_t resultsp" "const resultproc_t eachresult" 53db7534cfSBruce Evans.Fa "const int inittime" "const int waittime" 54db7534cfSBruce Evans.Fa "const char * nettype" 558360efbdSAlfred Perlstein.Fc 568360efbdSAlfred Perlstein.Ft "enum clnt_stat" 578360efbdSAlfred Perlstein.Fo rpc_call 588360efbdSAlfred Perlstein.Fa "const char *host" "const rpcprog_t prognum" 598360efbdSAlfred Perlstein.Fa "const rpcvers_t versnum" "const rpcproc_t procnum" 608360efbdSAlfred Perlstein.Fa "const xdrproc_t inproc" "const char *in" 618360efbdSAlfred Perlstein.Fa "const xdrproc_t outproc" "char *out" "const char *nettype" 628360efbdSAlfred Perlstein.Fc 638360efbdSAlfred Perlstein.Sh DESCRIPTION 648360efbdSAlfred PerlsteinRPC library routines allow C language programs to make procedure 658360efbdSAlfred Perlsteincalls on other machines across the network. 668360efbdSAlfred PerlsteinFirst, the client calls a procedure to send a request to the server. 678360efbdSAlfred PerlsteinUpon receipt of the request, the server calls a dispatch routine 688360efbdSAlfred Perlsteinto perform the requested service, and then sends back a reply. 698360efbdSAlfred Perlstein.Pp 708360efbdSAlfred PerlsteinThe 718360efbdSAlfred Perlstein.Fn clnt_call , 728360efbdSAlfred Perlstein.Fn rpc_call , 738360efbdSAlfred Perlsteinand 748360efbdSAlfred Perlstein.Fn rpc_broadcast 758360efbdSAlfred Perlsteinroutines handle the client side of the procedure call. 768360efbdSAlfred PerlsteinThe remaining routines deal with error handling in the case of errors. 778360efbdSAlfred Perlstein.Pp 788360efbdSAlfred PerlsteinSome of the routines take a 798360efbdSAlfred Perlstein.Vt CLIENT 808360efbdSAlfred Perlsteinhandle as one of the parameters. 818360efbdSAlfred PerlsteinA 828360efbdSAlfred Perlstein.Vt CLIENT 838360efbdSAlfred Perlsteinhandle can be created by an RPC creation routine such as 848360efbdSAlfred Perlstein.Fn clnt_create 858360efbdSAlfred Perlstein(see 868360efbdSAlfred Perlstein.Xr rpc_clnt_create 3 ) . 878360efbdSAlfred Perlstein.Pp 888360efbdSAlfred PerlsteinThese routines are safe for use in multithreaded applications. 898360efbdSAlfred Perlstein.Vt CLIENT 908360efbdSAlfred Perlsteinhandles can be shared between threads, however in this implementation 918360efbdSAlfred Perlsteinrequests by different threads are serialized (that is, the first request will 928360efbdSAlfred Perlsteinreceive its results before the second request is sent). 938360efbdSAlfred Perlstein.Sh Routines 948360efbdSAlfred PerlsteinSee 958360efbdSAlfred Perlstein.Xr rpc 3 968360efbdSAlfred Perlsteinfor the definition of the 978360efbdSAlfred Perlstein.Vt CLIENT 988360efbdSAlfred Perlsteindata structure. 998360efbdSAlfred Perlstein.Bl -tag -width XXXXX 1008360efbdSAlfred Perlstein.It Fn clnt_call 1018360efbdSAlfred PerlsteinA function macro that calls the remote procedure 1028360efbdSAlfred Perlstein.Fa procnum 1038360efbdSAlfred Perlsteinassociated with the client handle, 1048360efbdSAlfred Perlstein.Fa clnt , 1058360efbdSAlfred Perlsteinwhich is obtained with an RPC 1068360efbdSAlfred Perlsteinclient creation routine such as 1078360efbdSAlfred Perlstein.Fn clnt_create 1088360efbdSAlfred Perlstein(see 1098360efbdSAlfred Perlstein.Xr rpc_clnt_create 3 ) . 1108360efbdSAlfred PerlsteinThe parameter 1118360efbdSAlfred Perlstein.Fa inproc 1128360efbdSAlfred Perlsteinis the XDR function used to encode the procedure's parameters, and 1138360efbdSAlfred Perlstein.Fa outproc 1148360efbdSAlfred Perlsteinis the XDR function used to decode the procedure's results; 1158360efbdSAlfred Perlstein.Fa in 1168360efbdSAlfred Perlsteinis the address of the procedure's argument(s), and 1178360efbdSAlfred Perlstein.Fa out 1188360efbdSAlfred Perlsteinis the address of where to place the result(s). 1198360efbdSAlfred Perlstein.Fa tout 1208360efbdSAlfred Perlsteinis the time allowed for results to be returned, which is overridden by 1218360efbdSAlfred Perlsteina time-out set explicitly through 1228360efbdSAlfred Perlstein.Fn clnt_control , 1238360efbdSAlfred Perlsteinsee 1248360efbdSAlfred Perlstein.Xr rpc_clnt_create 3 . 1258360efbdSAlfred PerlsteinIf the remote call succeeds, the status returned is 1268360efbdSAlfred Perlstein.Dv RPC_SUCCESS , 1278360efbdSAlfred Perlsteinotherwise an appropriate status is returned. 1288360efbdSAlfred Perlstein.It Fn clnt_freeres 1298360efbdSAlfred PerlsteinA function macro that frees any data allocated by the 1308360efbdSAlfred PerlsteinRPC/XDR system when it decoded the results of an RPC call. 1318360efbdSAlfred PerlsteinThe parameter 1328360efbdSAlfred Perlstein.Fa out 1338360efbdSAlfred Perlsteinis the address of the results, and 1348360efbdSAlfred Perlstein.Fa outproc 1358360efbdSAlfred Perlsteinis the XDR routine describing the results. 1368360efbdSAlfred PerlsteinThis routine returns 1 if the results were successfully freed, 1378360efbdSAlfred Perlsteinand 0 otherwise. 1388360efbdSAlfred Perlstein.It Fn clnt_geterr 1398360efbdSAlfred PerlsteinA function macro that copies the error structure out of the client 1408360efbdSAlfred Perlsteinhandle to the structure at address 1418360efbdSAlfred Perlstein.Fa errp . 1428360efbdSAlfred Perlstein.It Fn clnt_perrno 1438360efbdSAlfred PerlsteinPrint a message to standard error corresponding 1448360efbdSAlfred Perlsteinto the condition indicated by 1458360efbdSAlfred Perlstein.Fa stat . 1468360efbdSAlfred PerlsteinA newline is appended. 1478360efbdSAlfred PerlsteinNormally used after a procedure call fails for a routine 1488360efbdSAlfred Perlsteinfor which a client handle is not needed, for instance 1498360efbdSAlfred Perlstein.Fn rpc_call . 1508360efbdSAlfred Perlstein.It Fn clnt_perror 1518360efbdSAlfred PerlsteinPrint a message to the standard error indicating why an 1528360efbdSAlfred PerlsteinRPC call failed; 1538360efbdSAlfred Perlstein.Fa clnt 1548360efbdSAlfred Perlsteinis the handle used to do the call. 1558360efbdSAlfred PerlsteinThe message is prepended with string 1568360efbdSAlfred Perlstein.Fa s 1578360efbdSAlfred Perlsteinand a colon. 1588360efbdSAlfred PerlsteinA newline is appended. 1598360efbdSAlfred PerlsteinNormally used after a remote procedure call fails 1608360efbdSAlfred Perlsteinfor a routine which requires a client handle, 1618360efbdSAlfred Perlsteinfor instance 1628360efbdSAlfred Perlstein.Fn clnt_call . 1638360efbdSAlfred Perlstein.It Fn clnt_sperrno 1648360efbdSAlfred PerlsteinTake the same arguments as 1658360efbdSAlfred Perlstein.Fn clnt_perrno , 1668360efbdSAlfred Perlsteinbut instead of sending a message to the standard error 1678360efbdSAlfred Perlsteinindicating why an RPC 1688360efbdSAlfred Perlsteincall failed, return a pointer to a string which contains the message. 1691fae73b1SRuslan ErmilovThe 1708360efbdSAlfred Perlstein.Fn clnt_sperrno 1711fae73b1SRuslan Ermilovfunction 1728360efbdSAlfred Perlsteinis normally used instead of 1738360efbdSAlfred Perlstein.Fn clnt_perrno 1748360efbdSAlfred Perlsteinwhen the program does not have a standard error (as a program 1758360efbdSAlfred Perlsteinrunning as a server quite likely does not), or if the programmer 1768360efbdSAlfred Perlsteindoes not want the message to be output with 1778360efbdSAlfred Perlstein.Fn printf 1788360efbdSAlfred Perlstein(see 1798360efbdSAlfred Perlstein.Xr printf 3 ) , 1808360efbdSAlfred Perlsteinor if a message format different than that supported by 1818360efbdSAlfred Perlstein.Fn clnt_perrno 1828360efbdSAlfred Perlsteinis to be used. 1838360efbdSAlfred PerlsteinNote: 1848360efbdSAlfred Perlsteinunlike 1858360efbdSAlfred Perlstein.Fn clnt_sperror 1868360efbdSAlfred Perlsteinand 18711d84435SRuslan Ermilov.Fn clnt_spcreateerror 1888360efbdSAlfred Perlstein(see 1898360efbdSAlfred Perlstein.Xr rpc_clnt_create 3 ) , 1908360efbdSAlfred Perlstein.Fn clnt_sperrno 1918360efbdSAlfred Perlsteindoes not return pointer to static data so the 1928360efbdSAlfred Perlsteinresult will not get overwritten on each call. 1938360efbdSAlfred Perlstein.It Fn clnt_sperror 1948360efbdSAlfred PerlsteinLike 1958360efbdSAlfred Perlstein.Fn clnt_perror , 1968360efbdSAlfred Perlsteinexcept that (like 1978360efbdSAlfred Perlstein.Fn clnt_sperrno ) 1988360efbdSAlfred Perlsteinit returns a string instead of printing to standard error. 1998360efbdSAlfred PerlsteinHowever, 2008360efbdSAlfred Perlstein.Fn clnt_sperror 2018360efbdSAlfred Perlsteindoes not append a newline at the end of the message. 2028360efbdSAlfred PerlsteinWarning: 2038360efbdSAlfred Perlsteinreturns pointer to a buffer that is overwritten 2048360efbdSAlfred Perlsteinon each call. 2058360efbdSAlfred Perlstein.It Fn rpc_broadcast 2068360efbdSAlfred PerlsteinLike 2078360efbdSAlfred Perlstein.Fn rpc_call , 2088360efbdSAlfred Perlsteinexcept the call message is broadcast to 2098360efbdSAlfred Perlsteinall the connectionless transports specified by 2108360efbdSAlfred Perlstein.Fa nettype . 2118360efbdSAlfred PerlsteinIf 2128360efbdSAlfred Perlstein.Fa nettype 2138360efbdSAlfred Perlsteinis 2148360efbdSAlfred Perlstein.Dv NULL , 2158360efbdSAlfred Perlsteinit defaults to 2168360efbdSAlfred Perlstein.Qq netpath . 2178360efbdSAlfred PerlsteinEach time it receives a response, 2188360efbdSAlfred Perlsteinthis routine calls 2198360efbdSAlfred Perlstein.Fn eachresult , 2208360efbdSAlfred Perlsteinwhose form is: 2218360efbdSAlfred Perlstein.Ft bool_t 2228360efbdSAlfred Perlstein.Fn eachresult "caddr_t out" "const struct netbuf * addr" "const struct netconfig * netconf" 2238360efbdSAlfred Perlsteinwhere 2248360efbdSAlfred Perlstein.Fa out 2258360efbdSAlfred Perlsteinis the same as 2268360efbdSAlfred Perlstein.Fa out 2278360efbdSAlfred Perlsteinpassed to 2288360efbdSAlfred Perlstein.Fn rpc_broadcast , 2298360efbdSAlfred Perlsteinexcept that the remote procedure's output is decoded there; 2308360efbdSAlfred Perlstein.Fa addr 2318360efbdSAlfred Perlsteinpoints to the address of the machine that sent the results, and 2328360efbdSAlfred Perlstein.Fa netconf 2338360efbdSAlfred Perlsteinis the netconfig structure of the transport on which the remote 2348360efbdSAlfred Perlsteinserver responded. 2358360efbdSAlfred PerlsteinIf 2368360efbdSAlfred Perlstein.Fn eachresult 2378360efbdSAlfred Perlsteinreturns 0, 2388360efbdSAlfred Perlstein.Fn rpc_broadcast 2398360efbdSAlfred Perlsteinwaits for more replies; 2408360efbdSAlfred Perlsteinotherwise it returns with appropriate status. 2418360efbdSAlfred PerlsteinWarning: 2428360efbdSAlfred Perlsteinbroadcast file descriptors are limited in size to the 2438360efbdSAlfred Perlsteinmaximum transfer size of that transport. 2448360efbdSAlfred PerlsteinFor Ethernet, this value is 1500 bytes. 2451fae73b1SRuslan ErmilovThe 2468360efbdSAlfred Perlstein.Fn rpc_broadcast 2471fae73b1SRuslan Ermilovfunction 2488360efbdSAlfred Perlsteinuses 2498360efbdSAlfred Perlstein.Dv AUTH_SYS 2508360efbdSAlfred Perlsteincredentials by default (see 2518360efbdSAlfred Perlstein.Xr rpc_clnt_auth 3 ) . 2528360efbdSAlfred Perlstein.It Fn rpc_broadcast_exp 2538360efbdSAlfred PerlsteinLike 2548360efbdSAlfred Perlstein.Fn rpc_broadcast , 2558360efbdSAlfred Perlsteinexcept that the initial timeout, 2568360efbdSAlfred Perlstein.Fa inittime 2578360efbdSAlfred Perlsteinand the maximum timeout, 2588360efbdSAlfred Perlstein.Fa waittime 2598360efbdSAlfred Perlsteinare specified in milliseconds. 2608360efbdSAlfred Perlstein.Fa inittime 2618360efbdSAlfred Perlsteinis the initial time that 2628360efbdSAlfred Perlstein.Fn rpc_broadcast_exp 2638360efbdSAlfred Perlsteinwaits before resending the request. 2648360efbdSAlfred PerlsteinAfter the first resend, the re-transmission interval 2658360efbdSAlfred Perlsteinincreases exponentially until it exceeds 2668360efbdSAlfred Perlstein.Fa waittime . 2678360efbdSAlfred Perlstein.It Fn rpc_call 2688360efbdSAlfred PerlsteinCall the remote procedure associated with 2698360efbdSAlfred Perlstein.Fa prognum , 2708360efbdSAlfred Perlstein.Fa versnum , 2718360efbdSAlfred Perlsteinand 2728360efbdSAlfred Perlstein.Fa procnum 2738360efbdSAlfred Perlsteinon the machine, 2748360efbdSAlfred Perlstein.Fa host . 2758360efbdSAlfred PerlsteinThe parameter 2768360efbdSAlfred Perlstein.Fa inproc 2778360efbdSAlfred Perlsteinis used to encode the procedure's parameters, and 2788360efbdSAlfred Perlstein.Fa outproc 2798360efbdSAlfred Perlsteinis used to decode the procedure's results; 2808360efbdSAlfred Perlstein.Fa in 2818360efbdSAlfred Perlsteinis the address of the procedure's argument(s), and 2828360efbdSAlfred Perlstein.Fa out 2838360efbdSAlfred Perlsteinis the address of where to place the result(s). 2848360efbdSAlfred Perlstein.Fa nettype 2858360efbdSAlfred Perlsteincan be any of the values listed on 2868360efbdSAlfred Perlstein.Xr rpc 3 . 2878360efbdSAlfred PerlsteinThis routine returns 2888360efbdSAlfred Perlstein.Dv RPC_SUCCESS 2898360efbdSAlfred Perlsteinif it succeeds, 2908360efbdSAlfred Perlsteinor an appropriate status is returned. 2918360efbdSAlfred PerlsteinUse the 2928360efbdSAlfred Perlstein.Fn clnt_perrno 2938360efbdSAlfred Perlsteinroutine to translate failure status into error messages. 2948360efbdSAlfred PerlsteinWarning: 2958360efbdSAlfred Perlstein.Fn rpc_call 2968360efbdSAlfred Perlsteinuses the first available transport belonging 2978360efbdSAlfred Perlsteinto the class 2988360efbdSAlfred Perlstein.Fa nettype , 2998360efbdSAlfred Perlsteinon which it can create a connection. 3008360efbdSAlfred PerlsteinYou do not have control of timeouts or authentication 3018360efbdSAlfred Perlsteinusing this routine. 3028360efbdSAlfred Perlstein.El 3038360efbdSAlfred Perlstein.Sh SEE ALSO 3048360efbdSAlfred Perlstein.Xr printf 3 , 3058360efbdSAlfred Perlstein.Xr rpc 3 , 3068360efbdSAlfred Perlstein.Xr rpc_clnt_auth 3 , 3078360efbdSAlfred Perlstein.Xr rpc_clnt_create 3 308