home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / tcpiptk / rpcgen / rguc.c < prev    next >
Text File  |  1999-05-11  |  3KB  |  69 lines

  1. /********************************************************copyrite.xic********/
  2. /*                                                                          */
  3. /*   Licensed Materials - Property of IBM                                   */
  4. /*   IBM TCP/IP for OS/2                                                    */
  5. /*   (C) Copyright IBM Corporation. 1990,1991.                              */
  6. /*                                                                          */
  7. /*   All rights reserved.                                                   */
  8. /*                                                                          */
  9. /*   US Government Users Restricted Rights -                                */
  10. /*   Use, duplication or disclosure restricted by GSA ADP Schedule          */
  11. /*   Contract with IBM Corp.                                                */
  12. /*                                                                          */
  13. /*--------------------------------------------------------------------------*/
  14. /*                                                                          */
  15. /*  DISCLAIMER OF WARRANTIES.  The following [enclosed] code is             */
  16. /*  sample code created by IBM Corporation. This sample code is not         */
  17. /*  part of any standard or IBM product and is provided to you solely       */
  18. /*  for  the purpose of assisting you in the development of your            */
  19. /*  applications.  The code is provided "AS IS", without                    */
  20. /*  warranty of any kind.  IBM shall not be liable for any damages          */
  21. /*  arising out of your use of the sample code, even if they have been      */
  22. /*  advised of the possibility of such damages.                             */
  23. /*--------------------------------------------------------------------------*/
  24. /* RGUC.C */
  25.  
  26. /* user written */
  27. /* client program */
  28.  
  29. #include <stdio.h>
  30. #include <rpc/rpc.h>
  31. #include "rg.h"
  32. #include <sys\socket.h>
  33. #include <netdb.h>
  34.  
  35. main(argc, argv)
  36.    int argc;
  37.    char *argv[];
  38. {
  39.    int *result;
  40.    char *message;
  41.    CLIENT *cl;
  42.    int socket = -1;
  43.    struct sockaddr_in addr;
  44.    struct hostent *hp;     /* Pointer to host info */
  45.  
  46.  
  47.    if (argc < 3)
  48.     {
  49.       fprintf(stderr, " Usage: rgc hostname user_input_string\n");
  50.       exit(-1);
  51.     }
  52.  
  53.    message = argv[2];
  54.  
  55.    hp = gethostbyname(argv[1]);
  56.    if (hp) {
  57.            addr.sin_family = hp->h_addrtype;
  58.            bcopy(hp->h_addr, (caddr_t)&(addr.sin_addr), hp->h_length);
  59.            addr.sin_port = (unsigned short) 0;
  60.    } else {
  61.            printf("unknown host\n");
  62.            exit(1);
  63.    }
  64.  
  65.    cl = clnttcp_create(&addr, MESSAGEPROG, MESSAGEVERS, &socket, 50, 500);
  66.    if (cl==NULL) exit(1);
  67.    result = printmessage_1(&message,cl);
  68. }
  69.