'\"macro stdmacro
.if n .pH g3n.rpc_clnt_cr @(#)rpc_clnt_cr	40.5 of 10/10/89
.\" Copyright 1989 AT&T
.\" ident	"@(#)svid_rs:rs_lib/rpc_clnt_creat	1.5"
.\" @(#)rpc_clnt_cre 1.5 89/07/24 SMI;
'\" macro stdmacro
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
.nr X
.if \nX=0 .ds x} rpc_clnt_create 3N "" "\&"
.if \nX=1 .ds x} rpc_clnt_create 3N ""
.if \nX=2 .ds x} rpc_clnt_create 3N "" "\&"
.if \nX=3 .ds x} rpc_clnt_create "" "" "\&"
.TH \*(x}
.SH NAME
.na
\f4rpc_clnt_create\fP:  \f4clnt_control\f1, \f4clnt_create\f1, \f4clnt_destroy\f1, \f4clnt_dg_create\f1, \f4clnt_pcreateerror\f1, \f4clnt_raw_create\f1, \f4clnt_spcreateerror\f1, \f4clnt_tli_create\f1, \f4clnt_tp_create\f1, \f4clnt_vc_create\f1 \- library routines for dealing with creation and manipulation of \f4CLIENT\fP handles
.ad
.SH DESCRIPTION
RPC library routines allow C language programs to make procedure
calls on other machines across the network.
First a
\f4CLIENT\fP
handle is created and then the client calls a procedure to send a
data packet to the server.
Upon receipt of the packet,
the server calls a dispatch routine
to perform the requested service,
and then sends back a reply.
.SS Routines
.P
See \f4rpc\fP(3N) for the definition of the 
\f4CLIENT\f1
data structure.
.P
.ft 4
.nf
.sp .5
#include <rpc/rpc.h>
.fi
.ft 1
.br
.if t .ne 10
.P
.ft 4
.nf
.sp .5
bool_t
clnt_control(CLIENT *clnt, const u_int req, char *info);
.fi
.ft 1
.IP
A function macro used to change or retrieve various information
about a client object.
\f2req\f1
indicates the type of operation,
and
\f2info\f1
is a pointer to the information.
For both
connectionless and connection-oriented transports,
the supported values of
\f2req\f1
and their argument types and what they do are:
.IP
.nf
.ta +1.25i +1.25i
\f4CLSET_TIMEOUT	struct timeval\f1	set total timeout
\f4CLGET_TIMEOUT	struct timeval\f1	get total timeout
.fi
.IP
Note: if you set the timeout using
\f4clnt_control\f1,
the timeout parameter passed to
\f4clnt_call\f1
will be ignored in all future calls.
.IP
.nf
.ta +1.25i +1.25i
\f4CLGET_FD	int\f1	get the associated file descriptor
\f4CLGET_SVC_ADDR	struct netbuf\f1	get servers address
\f4CLSET_FD_CLOSE	int\f1	close the file descriptor when
		destroying the client handle
		[see \f4clnt_destroy\f1]
\f4CLSET_FD_NCLOSE	int\f1	do not close the file
		descriptor when destroying
		the client handle
.fi
.br
.IP
The following operations are valid for
connectionless transports only:
.IP
.nf
.ta +1.55i +1.00i
\f4CLSET_RETRY_TIMEOUT	struct timeval\f1	set the retry timeout
\f4CLGET_RETRY_TIMEOUT	struct timeval\f1	get the retry timeout
.fi
.br
.IP
The retry timeout is the time that RPC
waits for the server to reply before
retransmitting the request.
.IP
\f4clnt_control\f1
returns \f41\f1 on success and \f40\f1 on failure.
.DT
.br
.if t .ne 10
.P
.ft 4
.nf
.sp .5
CLIENT *
clnt_create(const char *host, const u_long prognum,
	const u_long versnum, const char *nettype);
.fi
.ft 1
.IP
Generic client creation routine for program
\f2prognum\fP
and version
\f2versnum\fP.
\f2host\f1
identifies the name of the remote host where the server
is located.
\f2nettype\f1
indicates the class of transport protocol to use.
The transports are tried in
left to right order in
\f4NETPATH\f1
variable or in top to down order in
the netconfig database.
.IP
\f4clnt_create\f1
tries all the transports of the
\f2nettype\f1
class available from the
\f4NETPATH\f1
environment variable and the
the netconfig database,
and chooses the first successful one.
Default timeouts are set,
but can be modified using
\f4clnt_control\f1.
.br
.if t .ne 10
.P
.ft 4
.nf
.sp .5
void
clnt_destroy(CLIENT *clnt);
.fi
.ft 1
.IP
A function macro that destroys the client's
RPC handle.
Destruction usually involves deallocation
of private data structures,
including
\f2clnt\f1
itself.
Use of
\f2clnt\f1
is undefined after calling
\f4clnt_destroy\f1.
If the RPC
library opened the associated file descriptor,
or
\f4CLSET_FD_CLOSE\f1
was set using
\f4clnt_control\f1,
it will be closed.
.br
.if t .ne 15
.P
.ft 4
.nf
.sp .5
CLIENT *
clnt_dg_create(const int fd, const struct netbuf *svcaddr,
	const u_long prognum, const u_long versnum,
	const u_int sendsz, const u_int recvsz);
.fi
.ft 1
.IP
This routine creates an
RPC
client for the remote program
\f2prognum\f1
and version
\f2versnum\f1;
the client uses a connectionless transport.
The remote program is located at address
\f2svcaddr\f1.
The parameter
\f2fd\f1
is an open and bound file descriptor.
This routine will resend the call message in intervals of
15 seconds until a response is received or until the
call times out.
The total time for the call to time out is specified by
\f4clnt_call\f1
[see \f4clnt_call\f1 in
\f4rpc_clnt_calls\fP(3N)].
This routine returns \f4NULL\fP if it fails.
The retry time out and the total time out periods can
be changed using
\f4clnt_control\f1.
The user may set the size of the send and receive
buffers with the parameters
\f2sendsz\f1
and
\f2recvsz\f1;
values of \f40\f1 choose suitable defaults.
.br
.if t .ne 8
.P
.ft 4
.nf
.sp .5
void
clnt_pcreateerror(const char *s);
.fi
.ft 1
.IP
Print a message to standard error indicating
why a client RPC handle could not be created.
The message is prepended with the string
\f2s\f1
and a colon,
and appended with a
newline.
.br
.if t .ne 10
.P
.ft 4
.nf
.sp .5
CLIENT *
clnt_raw_create(const u_long prognum, const u_long versnum);
.fi
.ft 1
.IP
This routine creates a toy RPC
client for the remote program
\f2prognum\f1
and version
\f2versnum\f1.
The transport used to pass messages to the service is
a buffer within the process's address space,
so the corresponding RPC server should live in the same address space;
[see
\f4svc_raw_create\f1
in
\f4rpc_clnt_calls\fP(3N)].
This allows simulation of RPC
and acquisition of RPC overheads,
such as round trip times,
without any kernel interference.
This routine returns
\f4NULL\fP if it fails.
\f4clnt_raw_create\fP
should be called after
\f4svc_raw_create\fP.
.br
.if t .ne 9
.P
.ft 4
.nf
.sp .5
char *
clnt_spcreateerror(const char *s);
.fi
.ft 1
.IP
Like
\f4clnt_pcreateerror\f1,
except that it returns a string
instead of printing to the standard error.
A 
newline
is not appended to the message in this case.
.IP
Warning:
returns a pointer to static data that is overwritten
on each call.
.br
.if t .ne 15
.P
.ft 4
.nf
.sp .5
CLIENT *
clnt_tli_create(const int fd, const struct netconfig *netconf,
	const struct netbuf *svcaddr, u const_long prognum,
	const u_long versnum, const u_int sendsz,
	const u_int recvsz);
.fi
.ft 1
.IP
This routine creates an RPC
client handle for the remote program
\f2prognum\f1
and version
\f2versnum\f1.
The remote program is located at address
\f2svcaddr\f1.
If
\f2svcaddr\f1
is \f4NULL\fP
and it is connection-oriented,
it is assumed that the file descriptor is connected.
For connectionless transports,
if
\f2svcaddr\f1
is \f4NULL\fP,
\f4RPC_UNKNOWNADDR\f1
error is set.
\f2fd\f1
is a file descriptor which may be open, bound and connected.
If it is
\f4RPC_ANYFD\f1,
it opens a file descriptor on the transport
specified by
\f2netconf\f1.
If
\f2netconf\f1
is \f4NULL\fP, a
\f4RPC_UNKNOWNPROTO\f1
error is set.
If
\f2fd\f1
is unbound,
then it will attempt to bind the descriptor.
The user may specify the size of the buffers with the parameters
\f2sendsz\f1
and
\f2recvsz\f1;
values of \f40\f1 choose suitable defaults.
Depending upon the type of the transport (connection-oriented
or connectionless),
\f4clnt_tli_create\f1
calls appropriate client creation routines.
This routine returns
\f4NULL\fP if it fails.
The
\f4clnt_pcreaterror\f1
routine can be used to print the reason for failure.
The remote
\f4rpcbind\f1
service [see \f4rpcbind\fP(1M)]
will not be consulted for the address of the remote
service.
.br
.if t .ne 10
.P
.ft 4
.nf
.sp .5
CLIENT *
clnt_tp_create(const char *host, const u_long prognum,
	const u_long versnum, const struct netconfig *netconf);
.fi
.ft 1
.IP
\f4clnt_tp_create\f1
creates a client handle for the transport
specified by
\f2netconf\f1.
Default options are set,
which can be changed using
\f4clnt_control\f1
calls.
The remote
\f4rpcbind\f1
service on the host
\f2host\f1
is consulted for the address of the
remote service.
This routine returns \f4NULL\fP
if it fails.
The
\f4clnt_pcreaterror\f1
routine can be used to print the reason for failure.
.br
.if t .ne 15
.P
.ft 4
.nf
.sp .5
CLIENT *
clnt_vc_create(const int fd, const struct netbuf *svcaddr,
	const u_long prognum, const u_long versnum,
	const u_int sendsz, const u_int recvsz);
.fi
.ft 1
.IP
This routine creates an RPC
client for the remote program
\f2prognum\f1
and version
\f2versnum\f1;
the client uses a connection-oriented transport.
The remote program is located at address
\f2svcaddr\f1.
The parameter
\f2fd\f1
is an open and bound file descriptor.
The user may specify the size of the send and receive buffers
with the parameters
\f2sendsz\f1
and
\f2recvsz\f1;
values of \f40\f1 choose suitable defaults.
This routine returns \f4NULL\fP
if it fails.
.IP
The address
\f2svcaddr\f1
should not be \f4NULL\fP
and should point to the actual address of the remote program.
\f4clnt_vc_create\f1
will not consult the remote
\f4rpcbind\f1
service for this information.
.SH SEE ALSO
.na
\f4rpcbind\fP(1M),
\f4rpc\fP(3N),
\f4rpc_clnt_auth\fP(3N),
\f4rpc_clnt_calls\fP(3N).
.ad
