56 TProperty(LPCTSTR lpszName, DWORD
id, DWORD to = 0,
size_t sendSize = INVALID_SIZE,
size_t recvSize = INVALID_SIZE)
86 virtual bool Open(
void) = 0;
128 virtual size_t Send(
size_t size, LPCVOID P) = 0;
138 virtual size_t Receive(
size_t size, LPVOID _P) = 0;
192inline size_t BlockingReadFile(HANDLE hFile, HANDLE hEvent, DWORD wait,
size_t size, LPVOID _P)
194 OVERLAPPED overLapped = { 0 };
195 HANDLE hMyEvent = NULL;
196 if ( hEvent == NULL )
198 hMyEvent = ::CreateEvent(NULL, FALSE, TRUE, NULL);
199 ::ResetEvent(hMyEvent);
202 overLapped.hEvent = hEvent;
203 DWORD dwRc = ULONG_MAX;
204 DWORD work = ULONG_MAX;
205 if ( ::ReadFile(hFile, _P,
ToDword(size), &dwRc, &overLapped) )
209 else if ( ::GetLastError() == ERROR_IO_PENDING )
213 if( ::GetOverlappedResult(hFile, &overLapped, &work, FALSE) )
217 else if ( ::GetLastError() == ERROR_IO_INCOMPLETE )
219 switch ( ::WaitForSingleObject(overLapped.hEvent, wait) )
222 if ( ::GetOverlappedResult(hFile, &overLapped, &work, FALSE) )
238 if ( hMyEvent != NULL )
240 ::CloseHandle(hMyEvent);
247inline size_t BlockingReadFile(HANDLE hFile, HANDLE hEvent, DWORD wait,
size_t size, LPVOID _P)
249 DWORD dwRc = ULONG_MAX;
250 if ( ::ReadFile(hFile, _P,
ToDword(size), &dwRc, NULL) )
254 _GetLastError(
"ReadFile");
size_t BlockingReadFile(HANDLE hFile, HANDLE hEvent, DWORD wait, size_t size, LPVOID _P)
EVENT、Wait時間付き ReadFile関数
DWORD ToDword(LPCSTR lpsz, int iBase=10)
[変換] INT変換(ASCII/SJIS用).
size_t sendPacketSize
送信パケットサイズ。INVALID_SIZE なら制限なし。
DWORD receiveTimeout
受信待ち時間。 INFINITE ならブロックされる。
size_t receivePacketSize
受信パケットサイズ。INVALID_SIZE なら制限なし。
TProperty(LPCTSTR lpszName, DWORD id, DWORD to=0, size_t sendSize=INVALID_SIZE, size_t recvSize=INVALID_SIZE)
コンストラクタ
virtual EState Check(void) const
[確認] チェック.
virtual bool SetReceiveTimeout(DWORD to)=0
[設定] 受信待ち時間設定.
virtual bool Open(void)=0
[処理] オープン.
virtual bool IsOpened(void) const =0
[確認] オープン確認.
virtual bool CanSend(void) const
[確認] 送信可能確認.
virtual const TProperty & GetProperty(void) const =0
[取得] 性能取得.
virtual void Close(void)=0
[処理] クローズ.
virtual size_t Send(size_t size, LPCVOID P)=0
[処理] 送信.
virtual void Purge(void)
[処理] パージ.
virtual bool IsConnect(void) const
[確認] 接続確認.
virtual bool CanReceive(void) const
[確認] 受信可能確認.
virtual size_t Receive(size_t size, LPVOID _P)=0
[処理] 受信.
virtual size_t GetReceivingDataSize(void) const
[確認] 受信データ確認.
virtual ~ICommunication(void)
デストラクタ