home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / vsoup128.zip / socket.hh < prev    next >
Text File  |  1997-02-12  |  2KB  |  58 lines

  1. //  $Id: socket.hh 1.12 1997/02/12 08:48:50 hardy Exp $
  2. //
  3. //  This progam/module was written by Hardy Griech based on ideas and
  4. //  pieces of code from Chin Huang (cthuang@io.org).  Bug reports should
  5. //  be submitted to rgriech@ibm.net.
  6. //
  7. //  This file is part of soup++ for OS/2.  Soup++ including this file
  8. //  is freeware.  There is no warranty of any kind implied.  The terms
  9. //  of the GNU Gernal Public Licence are valid for this piece of software.
  10. //
  11.  
  12.  
  13. #ifndef __SOCKET_HH__
  14. #define __SOCKET_HH__
  15.  
  16.  
  17. class TSocket {
  18. public:
  19.     enum TState {init,connecting,connected,closed};
  20.  
  21. private:
  22.     TState State;
  23.     int  sock;
  24.     unsigned char *Buffer;
  25.     int  BuffSize;
  26.     int  BuffEnd;
  27.     int  BuffNdx;
  28.     const char *ipAdr;
  29.     const char *service;
  30.     const char *protocol;
  31.  
  32.     int send( const void *src, int len );
  33.     int nextchar( void );
  34.  
  35. public:
  36.     TSocket( void );
  37.     TSocket( const TSocket &right );     // copy constructor not allowed !
  38.     ~TSocket();
  39.     operator = (const TSocket &right);   // assignment operator not allowed !
  40.  
  41.     void close( void );
  42.     int open( const char *ipAdr, const char *service, const char *protocol,
  43.           int port=-1, int buffSize=4096 );
  44.     int printf( const char *fmt, ... ) __attribute__ ((format (printf, 2, 3)));
  45.     char *gets( char *buff, int bufflen );
  46.  
  47.     TState state( void ) { return State; }
  48.     const char *getIpAdr( void ) { return ipAdr; }
  49.     const char *getLocalhost( void );
  50.     
  51.     static unsigned long getBytesRcvd( void );
  52.     static unsigned long getBytesXmtd( void );
  53.     static void abortAll( void );
  54. };
  55.  
  56.  
  57. #endif
  58.