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