home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / TIERRA40.ZIP / ALMOND / ALCOMM / SRC / ATRY2.C < prev    next >
C/C++ Source or Header  |  1992-05-16  |  2KB  |  81 lines

  1. /*
  2. * try2.c
  3. *
  4. *
  5. * Copyright (c) 1991, 1992 by Marc W. Cygnus and Virtual Life
  6. * All Rights Reserved.
  7. *
  8. */
  9.  
  10.  
  11. #include <stdio.h>
  12. #include <sys/types.h>
  13.  
  14. #include <arpa/inet.h>
  15.  
  16. #include "alcomm.h"
  17. #include "alcommp.h"
  18. #include "debug.h"
  19.  
  20.  
  21.  
  22. int main( argc, argv )
  23.   int        argc;
  24.   char *    argv[];
  25. {
  26.   u_long        ulAddr;
  27.   int            iRet;
  28.   char *        sHostname;
  29.   int            iPort;
  30.   hALtCLink        hLink;
  31.   int            iMode;
  32.   pALtRequest        pReq;
  33.   char            sText[100];
  34.   int            iTLen;
  35.   int            iLoop;
  36.  
  37.   _debug_state = 0xffff;
  38.  
  39.   if ( argc != 3 ) {
  40.     puts( "Please specify no args *or* <hostname> <port>." );
  41.     exit( -1 );
  42.   }
  43.   printf( "trying %s : %s\n", argv[1], argv[2] );
  44.  
  45.   puts( "initialising alcomm" );
  46.   if (( iRet = ALCommInitialise( AL_Default, AL_Default )) < 0 )
  47.     ALGripe( "ALCommInitialise", "error %d\n", iRet ), exit( -1 );
  48.  
  49.   puts( "resolving host" );
  50.   iPort = atoi( argv[2] );
  51.   if (( iRet = ALInterpretHostAddress( argv[1], &sHostname, &ulAddr )
  52.       ) != ALsOK )
  53.     ALGripe( "AL call", "ALInterpretHostAddress returned %d\n", iRet ),
  54.       exit( -1 );
  55.  
  56.   puts( "trying connect" );
  57.   if (( iRet = ALOpenTCPPathway( ulAddr, iPort, AL_Default, &hLink )) != ALsOK)
  58.     ALGripe( "AL open call", "open tcp pathway returned %d\n", iRet ),
  59.       exit( -1 );
  60.  
  61.   printf( "operating with clink %d\n", hLink );
  62.  
  63.   iLoop = 0;
  64.   while ( 1 ) {
  65.  
  66.     printf( "==> " );
  67.     fflush( stdout );
  68.     gets( sText );
  69.     iTLen = strlen( sText ) + 1;
  70.     if (( iRet = ALTCPGenRequest( hLink, (u_char)iLoop, (u_char)255,
  71.                   (pALtOpaque)sText, iTLen )) < 0 )
  72.       ALGripe( "ALTCPGenRequest", "error %d\n", iRet ), exit( -1 );
  73.     iLoop++;
  74.   }
  75.  
  76. }
  77.  
  78.  
  79.  
  80. /* end try.c */
  81.