[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference lassie::ucx

Title:DEC TCP/IP Services for OpenVMS
Notice:Note 2-SSB Kits, 3-FT Kits, 4-Patch Info, 7-QAR System
Moderator:ucxaxp.ucx.lkg.dec.com::TIBBERT
Created:Thu Nov 17 1994
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:5568
Total number of notes:21492

5125.0. "ONC RPC clnttcp int *sockp gives wrong socket number. Why?" by ZUR01::DEMETRIOU () Thu Jan 16 1997 07:58

T.RTitleUserPersonal
Name
DateLines
5125.1I open an IPMT for this problemZUR01::DEMETRIOUFri Jan 17 1997 08:461
5125.2Here is the reply to the case ...UCXAXP::GEMIGNANIWed Jan 29 1997 23:29107
CFS-48145	IPMT ZUO101084	Akros AG, Severity 3  Reported release: V3.3
    
17-Jan-1997
~~~~~~~~~~~
The release which you are reporting the problem for is no longer supported.
I have tested it, however, with the currently supported releases and have
found that the program works properly.

I have made a few changes to your source code, as it was not using `sockp'
properly.  The routine clnttcp_create() expects to be passed an `int *', not
an `int **', as you have done.  See the definitions of `sock' and `sockp'
below.  Note that you can probably remove sockp and pass the address of sock
(&sock) instead.  That would simplify the variables.


/*
* rls.c: Remote directory listing client
*/
#include <errno.h>
#include <rms.h>
#include <stdio.h>
#include <in.h>
#include <netdb.h>
#include <UCX$INETDEF.H>
#include <UCX$RPCXDR.H>
#include <socket.h>
#include "dir.h"
main(argc, argv)
     int   argc;
     char *argv[];
{
     CLIENT *cl;
     char   *dir;
     static  struct  sockaddr_in sock2_name;
     struct  hostent         hostentstruct;
     struct  hostent         *hostentptr;
     namelist nl;
     readdir_res *result;
     char   *server;
     int     sock = RPC_ANYSOCK;
     int    *sockp = &sock;

    if (argc != 3) {
     fprintf(stderr, "usage: %s host directory\n", argv[0]);
     exit(1);
        }
        if ((hostentptr = gethostbyname (argv[1])) == NULL)
                {
                perror( "gethostbyname");
                exit(1);
                }
        hostentstruct = *hostentptr;
        sock2_name.sin_family = hostentstruct.h_addrtype;
        sock2_name.sin_port = 0;
sock2_name.sin_addr = * ((struct in_addr *) hostentstruct.h_addr);
    server = argv[1];
    dir = argv[2];
    /*
    ** Create client "handle" used for calling DIRPROG on
    ** the server designated on the command line.  Use
    ** the tcp protocol when contacting the server.
    */
 cl = clnttcp_create((struct sockaddr_in *)&sock2_name,
             DIRPROG, DIRVERS,sockp,0,0);
    if (cl == NULL) {
        /*
        ** Couldn't establish connection with server.
        ** Print error message and stop.
        */
        clnt_pcreateerror(server);
        exit(1);
        }
    /*
    ** Call the remote procedure readdir on the server
    */
    result = readdir_1(&dir, cl);
    if (result == NULL) {
       /*
       ** An RPC error occurred while calling the server.
       ** Print error message and stop.
       */
        clnt_perror(cl, server);
        exit(1);
        }
    /*
    ** Okay, we successfully called the remote procedure.
    */
    if (result->Errno != 0) {
        /*
        ** A remote system error occurred.
        ** Print error message and stop.
        **/
        errno = result->Errno;
        perror(dir);
        exit(1);
        }
    /*
    ** Successfully got a directory listing.
    ** Print it out.
    */
    for (nl = result->readdir_res_u.list;
             nl != NULL;
                 nl = nl->next)
        printf("%s\n", nl->name);
    exit(0);
    }