Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

TcpSocket.h

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002 
00003    Copyright (c) 2000 Tyrell Corporation. All rights reserved.
00004 
00005    Tyrell DarkIce
00006 
00007    File     : TcpSocket.h
00008    Version  : $Revision: 1.3 $
00009    Author   : $Author: darkeye $
00010    Location : $Source: /cvsroot/darkice/darkice/src/TcpSocket.h,v $
00011    
00012    Copyright notice:
00013 
00014     This program is free software; you can redistribute it and/or
00015     modify it under the terms of the GNU General Public License  
00016     as published by the Free Software Foundation; either version 2
00017     of the License, or (at your option) any later version.
00018    
00019     This program is distributed in the hope that it will be useful,
00020     but WITHOUT ANY WARRANTY; without even the implied warranty of 
00021     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
00022     GNU General Public License for more details.
00023    
00024     You should have received a copy of the GNU General Public License
00025     along with this program; if not, write to the Free Software
00026     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00027 
00028 ------------------------------------------------------------------------------*/
00029 #ifndef TCP_SOCKET_H
00030 #define TCP_SOCKET_H
00031 
00032 #ifndef __cplusplus
00033 #error This is a C++ include file
00034 #endif
00035 
00036 
00037 /* ============================================================ include files */
00038 
00039 #include "Source.h"
00040 #include "Sink.h"
00041 
00042 
00043 /* ================================================================ constants */
00044 
00045 
00046 /* =================================================================== macros */
00047 
00048 
00049 /* =============================================================== data types */
00050 
00057 class TcpSocket : public Source, public Sink
00058 {
00059     private:
00060 
00064         char              * host;
00065 
00069         unsigned short      port;
00070 
00074         int                 sockfd;
00075         
00083         void
00084         init (  const char        * host,
00085                 unsigned short      port )              throw ( Exception );
00086 
00092         void
00093         strip ( void )                                  throw ( Exception );
00094 
00095 
00096     protected:
00097 
00103         inline
00104         TcpSocket ( void )                             throw ( Exception )
00105         {
00106             throw Exception( __FILE__, __LINE__);
00107         }
00108 
00109 
00110     public:
00111 
00119         inline
00120         TcpSocket(   const char        * host,
00121                      unsigned short      port )         throw ( Exception )
00122         {
00123             init( host, port);
00124         }
00125 
00132         TcpSocket(   const TcpSocket &    ss )        throw ( Exception );
00133 
00139         inline virtual
00140         ~TcpSocket( void )                           throw ( Exception )
00141         {
00142             strip();
00143         }
00144 
00152         inline virtual TcpSocket &
00153         operator= ( const TcpSocket &    ss )        throw ( Exception );
00154 
00160         inline const char *
00161         getHost ( void ) const                      throw ()
00162         {
00163             return host;
00164         }
00165 
00171         inline unsigned int
00172         getPort ( void ) const                      throw ()
00173         {
00174             return port;
00175         }
00176 
00183         virtual bool
00184         open ( void )                               throw ( Exception );
00185 
00191         inline virtual bool
00192         isOpen ( void ) const                       throw ()
00193         {
00194             return sockfd != 0;
00195         }
00196 
00207         virtual bool
00208         canRead (      unsigned int    sec,
00209                        unsigned int    usec )       throw ( Exception );
00210 
00219         virtual unsigned int
00220         read (         void          * buf,
00221                        unsigned int    len )        throw ( Exception );
00222 
00223 
00234         virtual bool
00235         canWrite (     unsigned int    sec,
00236                        unsigned int    usec )       throw ( Exception );
00237 
00246         virtual unsigned int
00247         write (        const void    * buf,
00248                        unsigned int    len )        throw ( Exception );
00249 
00256         inline virtual void
00257         flush ( void )                              throw ( Exception )
00258         {
00259         }
00260 
00266         virtual void
00267         close ( void )                              throw ( Exception );
00268 };
00269 
00270 
00271 /* ================================================= external data structures */
00272 
00273 
00274 /* ====================================================== function prototypes */
00275 
00276 
00277 
00278 #endif  /* TCP_SOCKET_H */
00279 
00280 
00281 /*------------------------------------------------------------------------------
00282  
00283   $Source: /cvsroot/darkice/darkice/src/TcpSocket.h,v $
00284 
00285   $Log: TcpSocket.h,v $
00286   Revision 1.3  2000/11/12 14:54:50  darkeye
00287   added kdoc-style documentation comments
00288 
00289   Revision 1.2  2000/11/05 17:37:24  darkeye
00290   removed clone() functions
00291 
00292   Revision 1.1.1.1  2000/11/05 10:05:55  darkeye
00293   initial version
00294 
00295   
00296 ------------------------------------------------------------------------------*/
00297 

Generated on Thu Apr 14 13:59:13 2005 for DarkIce by  doxygen 1.4.1