namedPipeConnection.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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>
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
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