瀏覽代碼

Implemented and tested non-blocking read on Windows.


git-svn-id: https://svn.microneil.com/svn/CodeDweller/branches/adeniz_1@56 d34b734f-a00e-4b39-a726-e4eeb87269ab
adeniz_1
adeniz 10 年之前
父節點
當前提交
2b2910bf38
共有 1 個文件被更改,包括 18 次插入0 次删除
  1. 18
    0
      child.cpp

+ 18
- 0
child.cpp 查看文件

@@ -499,6 +499,23 @@ namespace CodeDweller {
size_t nBytesAvailable = egptr() - gptr();
#ifdef _WIN32
DWORD lpTotalBytesAvail;
if (!PeekNamedPipe(inputHandle,
NULL,
0,
NULL,
&lpTotalBytesAvail,
NULL)) {
throw std::runtime_error("Error from PeekNamedPipe: " +
getErrorText());
}
if (lpTotalBytesAvail > 0) {
nBytesAvailable++;
}
#else
fd_set readFd;
int retVal;
struct timeval timeout = {0, 0};
@@ -514,6 +531,7 @@ namespace CodeDweller {
} else if (retVal > 0) {
nBytesAvailable++;
}
#endif
return nBytesAvailable;

Loading…
取消
儲存