namedPipeConnection.h

00001 
00002 /* Copyright (c) 2005-2009, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License as published by the Free
00006  * Software Foundation; either version 2.1 of the License, or (at your option)
00007  * any later version.
00008  *  
00009  * This library is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00012  * details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this library; if not, write to the Free Software Foundation, Inc.,
00016  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00017  */
00018 
00019 #ifndef EQNET_NAMEDPIPECONNECTION_H
00020 #define EQNET_NAMEDPIPECONNECTION_H
00021 
00022 #include <eq/base/base.h>
00023 #include <eq/base/buffer.h> // member
00024 
00025 #ifdef WIN32
00026 #  include <eq/net/connection.h>
00027 #else
00028 #  include "fdConnection.h"
00029 #  include <netinet/in.h>
00030 #endif
00031 
00032 
00033 namespace eq
00034 {
00035 namespace net
00036 {
00040     class NamedPipeConnection
00041 #ifdef WIN32
00042         : public Connection
00043 #else
00044         : public FDConnection
00045 #endif
00046     {
00047     public:
00048         NamedPipeConnection();
00049 
00050         virtual bool connect();
00051         virtual bool listen();
00052         virtual void acceptNB();
00053         virtual ConnectionPtr acceptSync();
00054         
00055         virtual void close();
00056 
00057 
00058 #ifdef WIN32
00059         virtual Notifier getNotifier() const {
00060             return _read.hEvent; }
00061 #endif
00062 
00063     protected:
00064         virtual ~NamedPipeConnection();
00065 
00066         void _initAIOAccept();
00067         void _exitAIOAccept();
00068         void _initAIORead();
00069         void _exitAIORead();
00070 
00071 #ifdef WIN32
00072         virtual void readNB( void* buffer, const uint64_t bytes );
00073         virtual int64_t readSync( void* buffer, const uint64_t bytes );
00074         virtual int64_t write( const void* buffer, const uint64_t bytes );
00075 #else
00076 
00077 #endif
00078 
00079     private:
00080         bool _createNamedPipe();
00081 
00082 #ifdef WIN32
00083         HANDLE _readFD;
00084 
00085         bool _connectToNewClient( HANDLE hPipe ) ;
00086 
00087         // overlapped data structures
00088         OVERLAPPED _read;
00089         OVERLAPPED _write;
00090 
00091         CHECK_THREAD_DECLARE( _recvThread );
00092 
00093         std::string _getFilename() const;
00094 #endif
00095     };
00096 }
00097 }
00098 
00099 #endif //EQNET_NAMEDPIPECONNECTION_H 
Generated on Mon Aug 10 18:58:40 2009 for Equalizer 0.9 by  doxygen 1.5.8