45 : m_hRead(INVALID_HANDLE_VALUE), m_hWrite(INVALID_HANDLE_VALUE), m_dwPipeBufferSize(0), m_property(_T(
"Pipe"), TNBVIW_KIND_PIPE)
47 m_isActiveClient =
false;
64 m_dwPipeBufferSize = dwSize;
96 m_pipeName = lpszPipeName;
97 m_isModeClient = isClient;
112 SECURITY_ATTRIBUTES sa;
113 sa.lpSecurityDescriptor = NULL;
114 sa.nLength =
sizeof(SECURITY_ATTRIBUTES);
115 sa.bInheritHandle = TRUE;
116 return !! ::CreatePipe(&m_hRead, &m_hWrite, &sa, m_dwPipeBufferSize);
118 if ( m_isModeClient )
121 m_isActiveClient =
true;
122 m_hRead = INVALID_HANDLE_VALUE;
123 m_hWrite = INVALID_HANDLE_VALUE;
127 m_hRead = ::CreateNamedPipe(m_pipeName,
129 PIPE_TYPE_BYTE | PIPE_WAIT,
135 m_hWrite = INVALID_HANDLE_VALUE;
136 return m_hRead != INVALID_HANDLE_VALUE;
144 if ( m_hRead != INVALID_HANDLE_VALUE )
146 ::CloseHandle(m_hRead);
147 m_hRead = INVALID_HANDLE_VALUE;
149 if ( m_hWrite != INVALID_HANDLE_VALUE )
151 ::CloseHandle(m_hWrite);
152 m_hWrite = INVALID_HANDLE_VALUE;
154 m_isActiveClient =
false;
164 if ( m_isActiveClient )
168 return m_hRead != INVALID_HANDLE_VALUE;
178 virtual size_t Send(
size_t size, LPCVOID P)
183 if ( ::WriteFile(
GetWriteHandle(), P, down_cast<DWORD>(size), &dwWriten, NULL) )
198 virtual size_t Receive(
size_t size, LPVOID _P)
205 if ( l != INVALID_SIZE )
211 DWORD dwReadBytes = 0;
212 if ( !! ::ReadFile(m_hRead, _P, down_cast<DWORD>(l), &dwReadBytes, NULL) )
216 _GetLastError(
"ReadFile");
229 if ( m_hRead == INVALID_HANDLE_VALUE )
235 if ( ::PeekNamedPipe(m_hRead, NULL, 0, NULL, &dwAvail, NULL) )
239 if ( ! m_pipeName.
IsEmpty() && m_isModeClient )
241 m_hRead = INVALID_HANDLE_VALUE;
243 _GetLastError(
"PeekNamedPipe");
291 void m_OnActiveClient(
void)
const
293 if ( m_isActiveClient && ! m_pipeName.
IsEmpty() && m_isModeClient )
295 if ( m_hRead == INVALID_HANDLE_VALUE )
298 m_hRead = ::CreateFile(m_pipeName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
305 bool m_isActiveClient;
306 mutable HANDLE m_hRead;
308 DWORD m_dwPipeBufferSize;
309 TProperty m_property;
HANDLE GetReadHandle(void) const
[取得] 読み込みハンドル取得
virtual EState Check(void) const
[確認] チェック.
void SettingNamedPipe(LPCTSTR lpszPipeName, bool isClient)
[設定] パイプ名設定.
virtual bool SetReceiveTimeout(DWORD to)
[設定] 受信待ち時間設定.
virtual bool Open(void)
[処理] オープン.
HANDLE GetWriteHandle(void) const
[取得] 書き込みハンドル取得
void SetPipeBufferSize(DWORD dwSize=0)
[設定] パイプバッファサイズ設定
virtual void Purge(void)
[処理] パージ.
virtual void Close(void)
[処理] クローズ.
virtual bool IsOpened(void) const
[確認] オープン確認.
virtual size_t Receive(size_t size, LPVOID _P)
[処理] 受信.
virtual ~CPipe(void)
デストラクタ
virtual const TProperty & GetProperty(void) const
[取得] 性能取得.
virtual size_t GetReceivingDataSize(void) const
[確認] 受信データ確認.
virtual size_t Send(size_t size, LPCVOID P)
[処理] 送信.
bool IsEmpty(void) const
[確認] 空チェック
virtual bool IsConnect(void) const
[確認] 接続確認.