Home C-Bits Package Documentation Project Page

Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ServerSocket.h

Go to the documentation of this file.
00001 /* ====================================================================
00002  *              The CBITS Software License, Version 1.0
00003  *
00004  *               Copyright (c) 2002-2003 Bruce Lowery
00005  *                       All rights reserved
00006  *
00007  * Redistribution and use of this software, in source and binary forms, 
00008  * with or without modification, are permitted provided that the above 
00009  * copyright notice, this paragraph, and the following paragraph are 
00010  * retained in each source code file.
00011  *
00012  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00013  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00014  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00015  * DISCLAIMED.  IN NO EVENT SHALL BRUCE LOWERY OR OTHER CONTRIBUTORS 
00016  * TO THE CBITS LIBRARY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00017  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00018  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00019  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00020  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00021  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00022  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00023  * SUCH DAMAGE.
00024  * ====================================================================
00025  */
00026 #ifndef __SERVERSOCKET_H__
00027 #define __SERVERSOCKET_H__
00028 
00029 #include <cbits/Socket.h>
00030 #include <cbits/SocketException.h>
00031 
00032 //
00033 // For building a DLL
00034 
00035 #ifdef BUILD_DLL
00036 #define EXPORT __declspec(dllexport)
00037 #else
00038 #define EXPORT
00039 #endif
00040 
00041 
00042 namespace cbits {
00043 
00044 class Socket;
00045 
00055 class EXPORT ServerSocket
00056 {
00057 public:
00058 
00066     ServerSocket
00067     ( 
00068         const int port,      
00070         const int qdepth=15  
00074     )
00075         throw( SocketException );
00076 
00077 
00084     virtual ~ServerSocket();
00085 
00086 
00097     virtual Socket *accept
00098     (
00099         const long int msec=0 
00103     ) 
00104         throw( SocketException );
00105 
00106 
00111     void close();
00112 
00113 
00120     socket_t getHandle() const;
00121 
00122 
00130     const bool isError() const;
00131 
00132 
00137     inline const std::string& getError() const { return _errstr; }
00138 
00139 
00147     const int getSockOpt
00148     ( 
00149         const int level,  
00150         const int op_name,
00151         char* result,     
00152         int* result_len   
00153     ) const;
00154 
00155 
00174     std::ostream* getLogger() const;
00175 
00176 
00184     std::ostream* getLocalLogger() const;
00185 
00186 
00194     void setLocalLogger
00195     ( 
00196         std::ostream* os 
00197     ) const;
00198 
00199 
00212     void closeLocalLogger() const;
00213 
00214 
00227     static std::ostream* getGlobalLogger();
00228 
00229 
00248     static void setGlobalLogger
00249     ( 
00250         std::ostream* os  
00251     );
00252 
00253 
00266     static void closeGlobalLogger();
00267 
00268 
00269 
00270 protected:
00271 
00283     virtual const socket_t accept_h
00284     ( 
00285         const long int msec=0  
00291     ) 
00292         throw( SocketException );
00293 
00294 
00302     inline Socket* get_tcp_socket() const { return _ssock; }
00303     
00304 
00308     mutable bool         _error;
00309     
00310 
00314     mutable std::string  _errstr;
00315     
00316 
00320     mutable std::ostream* _llogr;
00321     
00322 
00327     static  std::ostream* _glogr;
00328 
00329 
00330 private:
00331 
00336     Socket* _ssock;
00337 
00338 
00344     mutable CriticalSection _read_csect;
00345 
00346 
00352     mutable CriticalSection _csect;
00353 };
00354 
00355 };
00356 
00357 #endif
00358 
00359 /*
00360  * $Id: ServerSocket.h,v 1.6 2002/10/12 02:19:56 brulow Exp $
00361  * 
00362  * History: (Add nothing manually below)
00363  * -----------------------------------------------------------------------
00364  *
00365  * $Log: ServerSocket.h,v $
00366  * Revision 1.6  2002/10/12 02:19:56  brulow
00367  * Add socket pkg unit tests
00368  *
00369  * Revision 1.5  2002/10/11 20:29:09  brulow
00370  * Add unit tests for sockets, fix some errors in Socket classes.
00371  *
00372  * Revision 1.4  2002/10/09 22:43:03  brulow
00373  * Improve documentation
00374  *
00375  * Revision 1.3  2002/09/27 22:04:16  brulow
00376  * Add history footer to all .h .cpp files
00377  *
00378  *
00379  */

Generated by
doxygen
Hosted by
SourceForge