home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / hamradio / wattcp.zip / SELECT.C < prev    next >
C/C++ Source or Header  |  1992-03-05  |  883b  |  29 lines

  1. #include <copyright.h>
  2. #include <wattcp.h>
  3.  
  4. /*
  5.  * sock_sselect - returns one of several constants indicating
  6.  *                SOCKESTABLISHED - tcp connection has been established
  7.  *                SOCKDATAREAY    - tcp/udp data ready for reading
  8.  *                SOCKCLOSED      - socket has been closed
  9.  */
  10.  
  11.  
  12. sock_sselect( sock_type *s, int waitstate )
  13. {
  14.     /* are we connected ? */
  15.     if ( waitstate == SOCKDATAREADY )
  16.         if ( s->tcp.rdatalen ) return( SOCKDATAREADY );
  17.     if ( s->tcp.ip_type == 0 ) return( SOCKCLOSED );
  18.     if ( waitstate == SOCKESTABLISHED ) {
  19.         if ( s->tcp.ip_type == UDP_PROTO ) return( SOCKESTABLISHED );
  20.         if ( s->tcp.state == tcp_StateESTAB ||
  21.              s->tcp.state == tcp_StateESTCL ||
  22.              s->tcp.state == tcp_StateCLOSWT )
  23.              return( SOCKESTABLISHED );
  24.  
  25.     }
  26.     return( 0 );
  27. }
  28.  
  29.