home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / RPCSMP.ZIP / RGUC.C < prev    next >
Text File  |  1992-12-10  |  2KB  |  64 lines

  1. /********************************************************copyrite.xic***/
  2. /*                                                                     */
  3. /*   Licensed Materials - Property of IBM                              */
  4. /*                                                                     */
  5. /*   This product contains "Restricted Materials of IBM":              */
  6. /*      Program Number:   5798RXW                                      */
  7. /*      Program Name:     IBM TCP/IP Version 1.2 for OS/2              */
  8. /*   (C) Copyright IBM Corporation. 1990, 1991.                        */
  9. /*                                                                     */
  10. /*   All rights reserved.                                              */
  11. /*                                                                     */
  12. /*   US Government Users Restricted Rights -                           */
  13. /*   Use, duplication or disclosure restricted by GSA ADP Schedule     */
  14. /*   Contract with IBM Corp.                                           */
  15. /*                                                                     */
  16. /*   See IBM Copyright Instructions.                                   */
  17. /*                                                                     */
  18. /********************************************************copyrite.xic***/
  19. /* RGUC.C */
  20.  
  21. /* user written */
  22. /* client program */
  23.  
  24. #include <stdio.h>
  25. #include <string.h>
  26. #include <process.h>
  27. #include <stdlib.h>
  28. #include <rpc/rpc.h>
  29. #include "rg.h"
  30. #include <sys\socket.h>
  31. #include <netdb.h>
  32.  
  33. int main(int argc, char **argv)
  34. {
  35.    int *result;
  36.    char *message;
  37.    CLIENT *cl;
  38.    short sock = -1;
  39.    struct sockaddr_in addr;
  40.    struct hostent *hp;     /* Pointer to host info */
  41.    if (argc<3) {
  42.      printf("usage is %s hostname message\n",argv[0]);
  43.      return 0;
  44.    }
  45.  
  46.    message = argv[2];
  47.  
  48.    hp = gethostbyname(argv[1]);
  49.    if (hp) {
  50.            addr.sin_family = hp->h_addrtype;
  51.            bcopy(hp->h_addr, (caddr_t)&(addr.sin_addr), hp->h_length);
  52.            addr.sin_port = (unsigned short) 0;
  53.    } else {
  54.            printf("unknown host\n");
  55.            return 1;
  56.    }
  57.  
  58.    cl = clnttcp_create(&addr, MESSAGEPROG, MESSAGEVERS, &sock, 50, 500);
  59.    if (cl==NULL) return 1;
  60.    result = printmessage_1(&message,cl);
  61.    printf("The result of the RPC call was %d\n",*result);
  62.    return *result;
  63. }
  64.