2 static char sfs_clnt_generic_id[] = "@(#)clnt_generic.c 2.1 97/10/23";
5 /* @(#)clnt_generic.c 2.2 88/08/01 4.0 RPCSRC */
7 * Copyright (c) 1992-1997,2001 by Standard Performance Evaluation Corporation
9 * Standard Performance Evaluation Corporation (SPEC)
10 * 6585 Merchant Place, Suite 100
13 * This product contains benchmarks acquired from several sources who
14 * understand and agree with SPEC's goal of creating fair and objective
15 * benchmarks to measure computer performance.
17 * This copyright notice is placed here only to protect SPEC in the
18 * event the source is misused in any manner that is contrary to the
19 * spirit, the goals and the intent of SPEC.
21 * The source code is provided to the user or company under the license
22 * agreement for the SPEC Benchmark Suite for this product.
25 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
26 * unrestricted use provided that this legend is included on all tape
27 * media and as a part of the software program in whole or part. Users
28 * may copy or modify Sun RPC without charge, but are not authorized
29 * to license or distribute it to anyone else except as part of a product or
30 * program developed by the user.
32 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
33 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
34 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
36 * Sun RPC is provided with no support and without any obligation on the
37 * part of Sun Microsystems, Inc. to assist in its use, correction,
38 * modification or enhancement.
40 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
41 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
42 * OR ANY PART THEREOF.
44 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
45 * or profits or other special, indirect and consequential damages, even if
46 * Sun has been advised of the possibility of such damages.
48 * Sun Microsystems, Inc.
50 * Mountain View, California 94043
52 #if !defined(lint) && defined(SCCSIDS)
53 static char sccsid[] = "@(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI";
56 * Copyright (C) 1987, Sun Microsystems, Inc.
61 #include "rpc/osdep.h"
66 * Generic client creation: takes (hostname, program-number, protocol) and
67 * returns client handle. Default options are set, which the user can
68 * change using the rpc equivalent of ioctl()'s.
71 clnt_create(char *hostname,
78 struct sockaddr_in sin;
83 h = gethostbyname(hostname);
85 rpc_createerr.cf_stat = RPC_UNKNOWNHOST;
88 if (h->h_addrtype != AF_INET) {
90 * Only support INET for now
92 rpc_createerr.cf_stat = RPC_SYSTEMERROR;
93 rpc_createerr.cf_error.re_errno = EAFNOSUPPORT;
96 sin.sin_family = h->h_addrtype;
98 memset(sin.sin_zero, '\0', sizeof(sin.sin_zero));
99 memmove((char*)&sin.sin_addr, h->h_addr, h->h_length);
100 p = getprotobyname(proto);
102 rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
103 rpc_createerr.cf_error.re_errno = EPFNOSUPPORT;
107 switch (p->p_proto) {
111 client = sfs_cudp_create(&sin, prog, vers, tv, &sock);
112 if (client == NULL) {
116 clnt_control(client, CLSET_TIMEOUT, &tv);
119 client = sfs_ctcp_create(&sin, prog, vers, &sock, 0, 0);
120 if (client == NULL) {
125 clnt_control(client, CLSET_TIMEOUT, &tv);
128 rpc_createerr.cf_stat = RPC_SYSTEMERROR;
129 rpc_createerr.cf_error.re_errno = EPFNOSUPPORT;