home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-4.ZIP / GSAMP / GSAMP.ZIP / EXAMP31.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-09  |  1.1 KB  |  44 lines

  1. /*
  2.  *  EXAMP31.C
  3.  *
  4.  *  The Greenleaf Comm Library
  5.  *
  6.  *  Copyright (C) 1989 Greenleaf Software Inc.  All Rights Reserved.
  7.  *
  8.  *  This example program forces the remote end to send an XOFF, and
  9.  *  detects it by using isxoffblocked().  I send data to our UNIX
  10.  *  system which is running "cat > dummy" with "stty ixoff".  I can't
  11.  *  reliably get XOFF chars until I get up to 38400.
  12.  *
  13.  */
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include "asiports.h"
  17. #include "ibmkeys.h"
  18. #include "gf.h"
  19.  
  20. void main( void );
  21.  
  22. void main()
  23. {
  24.     int status;
  25.  
  26.     status = asiopen( COM1, ASINOUT | BINARY | NORMALRX, 10000, 10000,
  27.                       38400L, P_NONE, 1, 8, ON, ON);
  28.     if ( status < ASSUCCESS ) {
  29.         printf( "Failed to open the port.  Status = %d\n", status );
  30.         exit( 1 );
  31.     }
  32.     asixon( COM1, 30, 70, XON, XOFF );
  33.     for ( ; ; ) {
  34.         asiputs( COM1, "Lots of test data\n", -1 );
  35.         if ( isxoffblocked( COM1 ) )
  36.             break;
  37.         if ( gfkbhit() )
  38.             break;
  39.    }
  40.    printf( "Received an XOFF, waiting for an XON\n" );
  41.    while ( isxoffblocked( COM1 ) ) ;
  42.    printf( "Received an XON\n" );
  43. }
  44.