Browse Source

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 years ago
parent
commit
2b2910bf38
1 changed files with 18 additions and 0 deletions
  1. 18
    0
      child.cpp

+ 18
- 0
child.cpp View File

size_t nBytesAvailable = egptr() - gptr(); 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; fd_set readFd;
int retVal; int retVal;
struct timeval timeout = {0, 0}; struct timeval timeout = {0, 0};
} else if (retVal > 0) { } else if (retVal > 0) {
nBytesAvailable++; nBytesAvailable++;
} }
#endif
return nBytesAvailable; return nBytesAvailable;

Loading…
Cancel
Save