rdk@manatee.cis.ufl.edu (Bobby Krupczak) (11/23/88)
Hi! I am doing a project for school involving RPCGEN, Sun's remote procedure call program compiler. I am currently using version 3.5. The latest version of the Documenation is Revision A of 9 May, 1988. My problem is that Sun's documentation does not match the RPCGEN version that I have. Their are several problems : first, the docs I have refer to a function called clnt_create. The function is supposed to set up or create the client handle to the server. This function does not seem to exist when I compile the program. When I substituted this function with clnttcp_create(), it compiled but then proceeded to crash. I was hoping to get assistance from anyone that : has experience using RPCGEN, anyone who write remote procedure calls, or anyone that might know where and how to get better, more accurate information. Thanks Bobby Krupczak rdk@beach.cis.ufl.edu
guy@auspex.UUCP (Guy Harris) (11/26/88)
>Their are several problems : first, the docs I have refer to a function >called clnt_create. The function is supposed to set up or create >the client handle to the server. This function does not seem to exist >when I compile the program. It exists in SunOS 4.0. The document version number and date you gave is that of "Network Programming" in the 4.0 DocuC5-A(TM). It may not exist in 3.5. Is the documentation you're using 3.5 documentation, 4.0 documentation, or something else? >When I substituted this function with clnttcp_create(), it compiled but >then proceeded to crash. The calling sequences of "clnt_create" and "clnttcp_create" are different. "clnt_create" is a wrapper that takes a host name, RPC program number, RPC version number, and protocol name and calls the appropriate "create" routine to create a client handle. "clnttcp_create" takes an Internet address, rather than a host name. What you have to do is get the Internet address of the host in question (using "gethostbyname" - make sure it's an Internet address that you get back), fill in a "sockaddr_in" structure (if you're not familiar with it, this is probably explained in some part of the networking tutorial documentation) by: setting the "sin_family" to the "h_addrtype" of what "gethostbyname" gave you (although you already checked to make sure it was AF_INET); setting the "sin_port" to zero; zeroing the "sin_zero" with "bzero"; copying "h_addr" of what "gethostbyname" gave you to the "sin_addr". Then pass a pointer to that "sockaddr_in" structure as the first argument to "clnttcp_create", pass the program and version number as the second and third arguments, pass a pointer to an "int" variable initialized to RPC_ANYSOCK as the fourth argument, and pass 0 as the fifth and sixth arguments. At least that's what "clnt_create" does; I presume that, or something similar, will do the right thing. (Now you know why "clnt_create" was provided!).