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 802efeeba5SRuslan Ermilovhandle as one of the arguments. 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 ) . 1102efeeba5SRuslan ErmilovThe 1118360efbdSAlfred Perlstein.Fa inproc 1122efeeba5SRuslan Ermilovargument 1132efeeba5SRuslan Ermilovis the XDR function used to encode the procedure's arguments, and 1148360efbdSAlfred Perlstein.Fa outproc 1158360efbdSAlfred Perlsteinis the XDR function used to decode the procedure's results; 1168360efbdSAlfred Perlstein.Fa in 1178360efbdSAlfred Perlsteinis the address of the procedure's argument(s), and 1188360efbdSAlfred Perlstein.Fa out 1198360efbdSAlfred Perlsteinis the address of where to place the result(s). 1202efeeba5SRuslan ErmilovThe 1218360efbdSAlfred Perlstein.Fa tout 1222efeeba5SRuslan Ermilovargument 1238360efbdSAlfred Perlsteinis the time allowed for results to be returned, which is overridden by 1248360efbdSAlfred Perlsteina time-out set explicitly through 1258360efbdSAlfred Perlstein.Fn clnt_control , 1268360efbdSAlfred Perlsteinsee 1278360efbdSAlfred Perlstein.Xr rpc_clnt_create 3 . 1288360efbdSAlfred PerlsteinIf the remote call succeeds, the status returned is 1298360efbdSAlfred Perlstein.Dv RPC_SUCCESS , 1308360efbdSAlfred Perlsteinotherwise an appropriate status is returned. 1318360efbdSAlfred Perlstein.It Fn clnt_freeres 1328360efbdSAlfred PerlsteinA function macro that frees any data allocated by the 1338360efbdSAlfred PerlsteinRPC/XDR system when it decoded the results of an RPC call. 1342efeeba5SRuslan ErmilovThe 1358360efbdSAlfred Perlstein.Fa out 1362efeeba5SRuslan Ermilovargument 1378360efbdSAlfred Perlsteinis the address of the results, and 1388360efbdSAlfred Perlstein.Fa outproc 1398360efbdSAlfred Perlsteinis the XDR routine describing the results. 1408360efbdSAlfred PerlsteinThis routine returns 1 if the results were successfully freed, 1418360efbdSAlfred Perlsteinand 0 otherwise. 1428360efbdSAlfred Perlstein.It Fn clnt_geterr 1438360efbdSAlfred PerlsteinA function macro that copies the error structure out of the client 1448360efbdSAlfred Perlsteinhandle to the structure at address 1458360efbdSAlfred Perlstein.Fa errp . 1468360efbdSAlfred Perlstein.It Fn clnt_perrno 1478360efbdSAlfred PerlsteinPrint a message to standard error corresponding 1488360efbdSAlfred Perlsteinto the condition indicated by 1498360efbdSAlfred Perlstein.Fa stat . 1508360efbdSAlfred PerlsteinA newline is appended. 1518360efbdSAlfred PerlsteinNormally used after a procedure call fails for a routine 1528360efbdSAlfred Perlsteinfor which a client handle is not needed, for instance 1538360efbdSAlfred Perlstein.Fn rpc_call . 1548360efbdSAlfred Perlstein.It Fn clnt_perror 1558360efbdSAlfred PerlsteinPrint a message to the standard error indicating why an 1568360efbdSAlfred PerlsteinRPC call failed; 1578360efbdSAlfred Perlstein.Fa clnt 1588360efbdSAlfred Perlsteinis the handle used to do the call. 1598360efbdSAlfred PerlsteinThe message is prepended with string 1608360efbdSAlfred Perlstein.Fa s 1618360efbdSAlfred Perlsteinand a colon. 1628360efbdSAlfred PerlsteinA newline is appended. 1638360efbdSAlfred PerlsteinNormally used after a remote procedure call fails 1648360efbdSAlfred Perlsteinfor a routine which requires a client handle, 1658360efbdSAlfred Perlsteinfor instance 1668360efbdSAlfred Perlstein.Fn clnt_call . 1678360efbdSAlfred Perlstein.It Fn clnt_sperrno 1688360efbdSAlfred PerlsteinTake the same arguments as 1698360efbdSAlfred Perlstein.Fn clnt_perrno , 1708360efbdSAlfred Perlsteinbut instead of sending a message to the standard error 1718360efbdSAlfred Perlsteinindicating why an RPC 1728360efbdSAlfred Perlsteincall failed, return a pointer to a string which contains the message. 1731fae73b1SRuslan ErmilovThe 1748360efbdSAlfred Perlstein.Fn clnt_sperrno 1751fae73b1SRuslan Ermilovfunction 1768360efbdSAlfred Perlsteinis normally used instead of 1778360efbdSAlfred Perlstein.Fn clnt_perrno 1788360efbdSAlfred Perlsteinwhen the program does not have a standard error (as a program 1798360efbdSAlfred Perlsteinrunning as a server quite likely does not), or if the programmer 1808360efbdSAlfred Perlsteindoes not want the message to be output with 1818360efbdSAlfred Perlstein.Fn printf 1828360efbdSAlfred Perlstein(see 1838360efbdSAlfred Perlstein.Xr printf 3 ) , 1848360efbdSAlfred Perlsteinor if a message format different than that supported by 1858360efbdSAlfred Perlstein.Fn clnt_perrno 1868360efbdSAlfred Perlsteinis to be used. 1878360efbdSAlfred PerlsteinNote: 1888360efbdSAlfred Perlsteinunlike 1898360efbdSAlfred Perlstein.Fn clnt_sperror 1908360efbdSAlfred Perlsteinand 19111d84435SRuslan Ermilov.Fn clnt_spcreateerror 1928360efbdSAlfred Perlstein(see 1938360efbdSAlfred Perlstein.Xr rpc_clnt_create 3 ) , 1948360efbdSAlfred Perlstein.Fn clnt_sperrno 1958360efbdSAlfred Perlsteindoes not return pointer to static data so the 1968360efbdSAlfred Perlsteinresult will not get overwritten on each call. 1978360efbdSAlfred Perlstein.It Fn clnt_sperror 1988360efbdSAlfred PerlsteinLike 1998360efbdSAlfred Perlstein.Fn clnt_perror , 2008360efbdSAlfred Perlsteinexcept that (like 2018360efbdSAlfred Perlstein.Fn clnt_sperrno ) 2028360efbdSAlfred Perlsteinit returns a string instead of printing to standard error. 2038360efbdSAlfred PerlsteinHowever, 2048360efbdSAlfred Perlstein.Fn clnt_sperror 2058360efbdSAlfred Perlsteindoes not append a newline at the end of the message. 2068360efbdSAlfred PerlsteinWarning: 2078360efbdSAlfred Perlsteinreturns pointer to a buffer that is overwritten 2088360efbdSAlfred Perlsteinon each call. 2098360efbdSAlfred Perlstein.It Fn rpc_broadcast 2108360efbdSAlfred PerlsteinLike 2118360efbdSAlfred Perlstein.Fn rpc_call , 2128360efbdSAlfred Perlsteinexcept the call message is broadcast to 2138360efbdSAlfred Perlsteinall the connectionless transports specified by 2148360efbdSAlfred Perlstein.Fa nettype . 2158360efbdSAlfred PerlsteinIf 2168360efbdSAlfred Perlstein.Fa nettype 2178360efbdSAlfred Perlsteinis 2188360efbdSAlfred Perlstein.Dv NULL , 2198360efbdSAlfred Perlsteinit defaults to 2208360efbdSAlfred Perlstein.Qq netpath . 2218360efbdSAlfred PerlsteinEach time it receives a response, 2228360efbdSAlfred Perlsteinthis routine calls 2238360efbdSAlfred Perlstein.Fn eachresult , 2248360efbdSAlfred Perlsteinwhose form is: 2258360efbdSAlfred Perlstein.Ft bool_t 2268360efbdSAlfred Perlstein.Fn eachresult "caddr_t out" "const struct netbuf * addr" "const struct netconfig * netconf" 2278360efbdSAlfred Perlsteinwhere 2288360efbdSAlfred Perlstein.Fa out 2298360efbdSAlfred Perlsteinis the same as 2308360efbdSAlfred Perlstein.Fa out 2318360efbdSAlfred Perlsteinpassed to 2328360efbdSAlfred Perlstein.Fn rpc_broadcast , 2338360efbdSAlfred Perlsteinexcept that the remote procedure's output is decoded there; 2348360efbdSAlfred Perlstein.Fa addr 2358360efbdSAlfred Perlsteinpoints to the address of the machine that sent the results, and 2368360efbdSAlfred Perlstein.Fa netconf 2378360efbdSAlfred Perlsteinis the netconfig structure of the transport on which the remote 2388360efbdSAlfred Perlsteinserver responded. 2398360efbdSAlfred PerlsteinIf 2408360efbdSAlfred Perlstein.Fn eachresult 2418360efbdSAlfred Perlsteinreturns 0, 2428360efbdSAlfred Perlstein.Fn rpc_broadcast 2438360efbdSAlfred Perlsteinwaits for more replies; 2448360efbdSAlfred Perlsteinotherwise it returns with appropriate status. 2458360efbdSAlfred PerlsteinWarning: 2468360efbdSAlfred Perlsteinbroadcast file descriptors are limited in size to the 2478360efbdSAlfred Perlsteinmaximum transfer size of that transport. 2488360efbdSAlfred PerlsteinFor Ethernet, this value is 1500 bytes. 2491fae73b1SRuslan ErmilovThe 2508360efbdSAlfred Perlstein.Fn rpc_broadcast 2511fae73b1SRuslan Ermilovfunction 2528360efbdSAlfred Perlsteinuses 2538360efbdSAlfred Perlstein.Dv AUTH_SYS 2548360efbdSAlfred Perlsteincredentials by default (see 2558360efbdSAlfred Perlstein.Xr rpc_clnt_auth 3 ) . 2568360efbdSAlfred Perlstein.It Fn rpc_broadcast_exp 2578360efbdSAlfred PerlsteinLike 2588360efbdSAlfred Perlstein.Fn rpc_broadcast , 2598360efbdSAlfred Perlsteinexcept that the initial timeout, 2608360efbdSAlfred Perlstein.Fa inittime 2618360efbdSAlfred Perlsteinand the maximum timeout, 2628360efbdSAlfred Perlstein.Fa waittime 2638360efbdSAlfred Perlsteinare specified in milliseconds. 2642efeeba5SRuslan ErmilovThe 2658360efbdSAlfred Perlstein.Fa inittime 2662efeeba5SRuslan Ermilovargument 2678360efbdSAlfred Perlsteinis the initial time that 2688360efbdSAlfred Perlstein.Fn rpc_broadcast_exp 2698360efbdSAlfred Perlsteinwaits before resending the request. 2708360efbdSAlfred PerlsteinAfter the first resend, the re-transmission interval 2718360efbdSAlfred Perlsteinincreases exponentially until it exceeds 2728360efbdSAlfred Perlstein.Fa waittime . 2738360efbdSAlfred Perlstein.It Fn rpc_call 2748360efbdSAlfred PerlsteinCall the remote procedure associated with 2758360efbdSAlfred Perlstein.Fa prognum , 2768360efbdSAlfred Perlstein.Fa versnum , 2778360efbdSAlfred Perlsteinand 2788360efbdSAlfred Perlstein.Fa procnum 2798360efbdSAlfred Perlsteinon the machine, 2808360efbdSAlfred Perlstein.Fa host . 2812efeeba5SRuslan ErmilovThe 2828360efbdSAlfred Perlstein.Fa inproc 2832efeeba5SRuslan Ermilovargument 2842efeeba5SRuslan Ermilovis used to encode the procedure's arguments, and 2858360efbdSAlfred Perlstein.Fa outproc 2868360efbdSAlfred Perlsteinis used to decode the procedure's results; 2878360efbdSAlfred Perlstein.Fa in 2888360efbdSAlfred Perlsteinis the address of the procedure's argument(s), and 2898360efbdSAlfred Perlstein.Fa out 2908360efbdSAlfred Perlsteinis the address of where to place the result(s). 2912efeeba5SRuslan ErmilovThe 2928360efbdSAlfred Perlstein.Fa nettype 2932efeeba5SRuslan Ermilovargument 2948360efbdSAlfred Perlsteincan be any of the values listed on 2958360efbdSAlfred Perlstein.Xr rpc 3 . 2968360efbdSAlfred PerlsteinThis routine returns 2978360efbdSAlfred Perlstein.Dv RPC_SUCCESS 2988360efbdSAlfred Perlsteinif it succeeds, 2998360efbdSAlfred Perlsteinor an appropriate status is returned. 3008360efbdSAlfred PerlsteinUse the 3018360efbdSAlfred Perlstein.Fn clnt_perrno 3028360efbdSAlfred Perlsteinroutine to translate failure status into error messages. 3038360efbdSAlfred PerlsteinWarning: 3048360efbdSAlfred Perlstein.Fn rpc_call 3058360efbdSAlfred Perlsteinuses the first available transport belonging 3068360efbdSAlfred Perlsteinto the class 3078360efbdSAlfred Perlstein.Fa nettype , 3088360efbdSAlfred Perlsteinon which it can create a connection. 3098360efbdSAlfred PerlsteinYou do not have control of timeouts or authentication 3108360efbdSAlfred Perlsteinusing this routine. 3118360efbdSAlfred Perlstein.El 3128360efbdSAlfred Perlstein.Sh SEE ALSO 3138360efbdSAlfred Perlstein.Xr printf 3 , 3148360efbdSAlfred Perlstein.Xr rpc 3 , 3158360efbdSAlfred Perlstein.Xr rpc_clnt_auth 3 , 3168360efbdSAlfred Perlstein.Xr rpc_clnt_create 3 317