1 /*********************************************************************
2 * RPC for the Windows NT Operating System
3 * 1993 by Martin F. Gergeleit
4 * Users may use, copy or modify Sun RPC for the Windows NT Operating
5 * System according to the Sun copyright below.
7 * RPC for the Windows NT Operating System COMES WITH ABSOLUTELY NO
8 * WARRANTY, NOR WILL I BE LIABLE FOR ANY DAMAGES INCURRED FROM THE
9 * USE OF. USE ENTIRELY AT YOUR OWN RISK!!!
10 *********************************************************************/
12 /* @(#)clnt_generic.c 2.2 88/08/01 4.0 RPCSRC */
14 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
15 * unrestricted use provided that this legend is included on all tape
16 * media and as a part of the software program in whole or part. Users
17 * may copy or modify Sun RPC without charge, but are not authorized
18 * to license or distribute it to anyone else except as part of a product or
19 * program developed by the user.
21 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
22 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
25 * Sun RPC is provided with no support and without any obligation on the
26 * part of Sun Microsystems, Inc. to assist in its use, correction,
27 * modification or enhancement.
29 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
30 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
31 * OR ANY PART THEREOF.
33 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
34 * or profits or other special, indirect and consequential damages, even if
35 * Sun has been advised of the possibility of such damages.
37 * Sun Microsystems, Inc.
39 * Mountain View, California 94043
41 #if !defined(lint) && defined(SCCSIDS)
42 static char sccsid[] = "@(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI";
45 * Copyright (C) 1987, Sun Microsystems, Inc.
52 #include <sys/socket.h>
53 #include <sys/errno.h>
58 * Generic client creation: takes (hostname, program-number, protocol) and
59 * returns client handle. Default options are set, which the user can
60 * change using the rpc equivalent of ioctl()'s.
63 clnt_create(hostname, prog, vers, proto)
71 struct sockaddr_in sin;
76 h = gethostbyname(hostname);
78 rpc_createerr.cf_stat = RPC_UNKNOWNHOST;
81 if (h->h_addrtype != AF_INET) {
83 * Only support INET for now
85 rpc_createerr.cf_stat = RPC_SYSTEMERROR;
87 rpc_createerr.cf_error.re_errno = WSAEAFNOSUPPORT;
89 rpc_createerr.cf_error.re_errno = EAFNOSUPPORT;
93 sin.sin_family = h->h_addrtype;
95 bzero(sin.sin_zero, sizeof(sin.sin_zero));
96 bcopy(h->h_addr, (char*)&sin.sin_addr, h->h_length);
97 p = getprotobyname(proto);
99 rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
101 rpc_createerr.cf_error.re_errno = WSAEPFNOSUPPORT;
103 rpc_createerr.cf_error.re_errno = EPFNOSUPPORT;
108 switch (p->p_proto) {
112 client = clntudp_create(&sin, prog, vers, tv, &sock);
113 if (client == NULL) {
117 clnt_control(client, CLSET_TIMEOUT, &tv);
120 client = clnttcp_create(&sin, prog, vers, &sock, 0, 0);
121 if (client == NULL) {
126 clnt_control(client, CLSET_TIMEOUT, &tv);
129 rpc_createerr.cf_stat = RPC_SYSTEMERROR;
131 rpc_createerr.cf_error.re_errno = WSAEPFNOSUPPORT;
133 rpc_createerr.cf_error.re_errno = EPFNOSUPPORT;