.\" @(#)rpc_clnt_calls.3n 1.7 91/03/11 TIRPC 1.0; .TH RPC_CLNT_CALLS 3N "27 August 1990" .SH NAME callrpc, clnt_broadcast, clnt_call, clnt_freeres, clnt_geterr, clnt_perrno, clnt_perror, clnt_sperrno, clnt_sperror, rpc_broadcast, rpc_call \- library routines for client side calls .SH DESCRIPTION .IX "rpc routines" "callrpc()" "" "\fLcallrpc()\fP \(em client side calls" .IX "rpc routines" "clnt_broadcast()" "" "\fLclnt_broadcast()\fP \(em client side calls" .IX "rpc routines" "clnt_call()" "" "\fLclnt_call()\fP \(em client side calls" .IX "rpc routines" "clnt_freeres()" "" "\fLclnt_freeres()\fP \(em client side calls" .IX "rpc routines" "clnt_geterr()" "" "\fLclnt_geterr()\fP \(em client side calls" .IX "rpc routines" "clnt_perrno()" "" "\fLclnt_perrno()\fP \(em client side calls" .IX "rpc routines" "clnt_perror()" "" "\fLclnt_perror()\fP \(em client side calls" .IX "rpc routines" "clnt_sperrno()" "" "\fLclnt_sperrno()\fP \(em client side calls" .IX "rpc routines" "clnt_sperror()" "" "\fLclnt_sperror()\fP \(em client side calls" .IX "rpc routines" "rpc_broadcast()" "" "\fLrpc_broadcast()\fP \(em client side calls" .IX "rpc routines" "rpc_call()" "" "\fLrpc_call()\fP \(em client side calls" .IX "callrpc()" "" "\fLcallrpc()\fP \(em client side calls" .IX "clnt_broadcast()" "" "\fLclnt_broadcast()\fP \(em client side calls" .IX "clnt_call()" "" "\fLclnt_call()\fP \(em client side calls" .IX "clnt_freeres()" "" "\fLclnt_freeres()\fP \(em client side calls" .IX "clnt_geterr()" "" "\fLclnt_geterr()\fP \(em client side calls" .IX "clnt_perrno()" "" "\fLclnt_perrno()\fP \(em client side calls" .IX "clnt_perror()" "" "\fLclnt_perror()\fP \(em client side calls" .IX "clnt_sperrno()" "" "\fLclnt_sperrno()\fP \(em client side calls" .IX "clnt_sperror()" "" "\fLclnt_sperror()\fP \(em client side calls" .IX "rpc_broadcast()" "" "\fLrpc_broadcast()\fP \(em client side calls" .IX "rpc_call()" "" "\fLrpc_call()\fP \(em client side calls" .LP .SM RPC routines allow C programs to make procedure calls on other machines across the network. First, the client calls a procedure to send a request to the server. Upon receipt of the request, the server calls a dispatch routine to perform the requested service, and then sends back a reply. Finally, the procedure call returns to the client. .LP The .BR clnt_call(\|) , .B callrpc(\|) , .B clnt_broadcast(\|) , .B rpc_broadcast(\|) , and .B rpc_call(\|) routines handle the client side of the procedure call. The remaining routines deal with error handling in the case of errors. .SS Routines .LP .ft B .nf .sp .5 #include .fi .ft 1 .br .if t .ne 13 .LP .ft B .nf .sp .5 callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) char *host; u_long prognum, versnum, procnum; char *in; xdrproc_t inproc; char *out; xdrproc_t outproc; .fi .ft R .IP Call the remote procedure associated with .IR prognum , .IR versnum , and .I procnum on the machine, .IR host . The parameter .I in is the address of the procedure's argument, and .I out is the address of where to place the result(s); .I inproc is used to encode the procedure's parameters, and .I outproc is used to decode the procedure's results. This routine returns zero if it succeeds, or the value of .B "enum clnt_stat" cast to an integer if it fails. The routine .B clnt_perrno(\|) is handy for translating failure statuses into messages. .IP Warning: You do not have control of timeouts or authentication using this routine. This routine exists for backward compatibility only, and is obsoleted by .BR rpc_call(\|) . .br .if t .ne 16 .LP .ft B .nf .sp .5 enum clnt_stat clnt_broadcast(prognum, versnum, procnum, inproc, in, outproc, out, eachresult) u_long prognum, versnum, procnum; char *in; xdrproc_t inproc; char *out; xdrproc_t outproc; resultproc_t eachresult; .fi .ft R .IP Like .BR callrpc(\|) , except the call message is broadcast to all locally connected broadcast nets. Each time the caller receives a response, this routine calls .BR eachresult(\|) , whose form is: .RS 1i .ft B .nf eachresult(out, addr) char *out; struct sockaddr_in *addr; .ft R .fi .RE .IP where .I out is the same as .I out passed to .BR clnt_broadcast(\|) , except that the remote procedure's output is decoded there; .I addr points to the address of the machine that sent the results. If .B eachresult(\|) returns zero .B clnt_broadcast(\|) waits for more replies; otherwise it returns with appropriate status. If .B eachresult(\|) is .SM NULL\s0, .B clnt_broadcast(\|) returns without waiting for any replies. .br .ne 6 .IP Warning: Broadcast packets are limited in size to the maximum transfer unit of the transports involved. For Ethernet, the callers argument size is approximately 1500 bytes. Since the call message is sent to all connected networks, it may potentially lead to broadcast storms. This routine exists for backward compatibility only, and is obsoleted by .B rpc_broadcast(\|) . .br .if t .ne 13 .LP .ft B .nf .sp .5 enum clnt_stat clnt_call(clnt, procnum, inproc, in, outproc, out, tout) \s-1CLIENT\s0 *clnt; u_long procnum; xdrproc_t inproc, outproc; char *in, *out; struct timeval tout; .fi .ft R .IP A function macro that calls the remote procedure .I procnum associated with the client handle, .IR clnt , which is obtained with an .SM RPC client creation routine such as .B clnt_create(\|) (see .BR rpc_clnt_create (3N) ). The parameter .I in is the address of the procedure's argument(s), and .I out is the address of where to place the result(s); .I inproc is used to encode the procedure's parameters, and .I outproc is used to decode the procedure's results; .I tout is the time allowed for results to come back. .br .if t .ne 10 .LP .ft B .nf .sp .5 clnt_freeres(clnt, outproc, out) \s-1CLIENT\s0 *clnt; xdrproc_t outproc; char *out; .fi .ft R .IP A function macro that frees any data allocated by the .SM RPC/XDR system when it decoded the results of an .SM RPC call. The parameter .I out is the address of the results, and .I outproc is the .SM XDR routine describing the results. This routine returns one if the results were successfully freed, and zero otherwise. .br .if t .ne 6 .LP .ft B .nf .sp .5 void clnt_geterr(clnt, errp) \s-1CLIENT\s0 *clnt; struct rpc_err *errp; .fi .ft R .IP A function macro that copies the error structure out of the client handle to the structure at address .IR errp . .br .if t .ne 8 .LP .ft B .nf .sp .5 void clnt_perrno(stat) enum clnt_stat stat; .fi .ft R .IP Print a message to the standard error corresponding to the condition indicated by .IR stat . Used after .BR rpc_call(\|) or .BR rpc_broadcast(\|) . .br .if t .ne 8 .LP .ft B .nf .sp .5 void clnt_perror(clnt, s) \s-1CLIENT\s0 *clnt; char *s; .fi .ft R .IP Print a message to the standard error indicating why an .SM RPC call failed; .I clnt is the handle used to do the call. The message is prepended with string .I s and a colon. Used after .BR clnt_call(\|) . .br .if t .ne 9 .LP .ft B .nf .sp .5 char * clnt_sperrno(stat) enum clnt_stat stat; .fi .ft R .IP Take the same arguments as .BR clnt_perrno(\|) , but instead of sending a message to the standard error indicating why an .SM RPC call failed, return a pointer to a string which contains the message. The string does not end with a .SM NEWLINE . .IP .BR clnt_sperrno(\|) is used instead of .BR clnt_perrno(\|) if the program does not have a standard error (as a program running as a server quite likely does not), or if the programmer does not want the message to be output with .BR printf(\|), or if a message format different than that supported by .BR clnt_perrno(\|) is to be used. Note: unlike .BR clnt_sperror(\|) and .BR clnt_spcreateerror(\|) , .BR clnt_sperrno(\|) does not return pointer to static data so the result will not get overwritten on each call. .LP .ft B .nf .sp .5 char * clnt_sperror(clnt, s) \s-1CLIENT\s0 *clnt; char *s; .fi .ft R .IP Like .BR clnt_perror(\|) , except that (like .BR clnt_sperrno(\|) ) it returns a string instead of printing to the standard error. The string does not end with a .SM NEWLINE\s0. .IP Warning: returns pointer to static data that is overwritten on each call. .br .if t .ne 16 .LP .ft B .nf .sp .5 enum clnt_stat rpc_broadcast(prognum, versnum, procnum, inproc, in, outproc, out, eachresult, nettype) u_long prognum, versnum, procnum; xdrproc_t inproc, outproc; char *in, *out, *nettype; resultproc_t eachresult; .fi .ft R .IP Like .BR rpc_call(\|) , except the call message is broadcast to all the networks specified by .I nettype that support broadcasts. If .I nettype is .SM NULL\s0, it defaults to the datagram transports specified in .BR \s-1NETPATH\s0 which support broadcasts. Each time it receives a response, this routine calls .BR eachresult(\|) , whose form is: .IP .RS 1i .ft B .nf eachresult(out, addr, netconf) char *out; struct netbuf *addr; struct netconfig *netconf; .ft R .fi .RE .IP where .I out is the same as .I out passed to .BR rpc_broadcast(\|) , except that the remote procedure's output is decoded there; .I addr points to the address of the machine that sent the results; and .I netconf is the netconfig structure of the transport on which the remote machine responded. If .B eachresult(\|) returns zero, .B rpc_broadcast(\|) waits for more replies; otherwise it returns with appropriate status. .IP Warning: broadcast messages are limited in size to the maximum transfer size of that transport. For Ethernet, this value is approximately 1500 bytes. .br .if t .ne 13 .LP .ft B .nf .sp .5 enum clnt_stat rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype) char *host; u_long prognum, versnum, procnum; xdrproc_t inproc, outproc; char *in, *out, *nettype; .fi .ft R .IP Call the remote procedure associated with .IR prognum , .IR versnum , and .I procnum on the machine, .IR host . The parameter .I in is the address of the procedure's argument(s), and .I out is the address of where to place the result(s); .I inproc is used to encode the procedure's parameters, and .I outproc is used to decode the procedure's results. .I nettype can be any of the values listed in the DESCRIPTION. If .I nettype is .SM NULL\s0, it defaults to .BR \s-1NETPATH\s0 . This routine returns zero if it succeeds, or the value .B enum clnt_stat if it fails. The routine .B clnt_perrno(\|) is handy for translating failure statuses into messages. .IP Warning: .B rpc_call(\|) uses the first transport belonging to the class .IR nettype , on which it can create a connection. You do not have control of timeouts or authentication using this routine. .SH SEE ALSO .BR printf (3V), .BR rpc (3N), .BR rpc_clnt_auth (3N), .BR rpc_clnt_create (3N)