Is it possible to use WaitForMultipleObjects() with ACE_SOCK_Stream, and make it return only when there's data to read from it?
I tried to following:
// set some params
DWORD handlesCount = 1;
DWORD timeoutMs = 5 * 1000;
HANDLE* handles = new HANDLE[handlesCount];
handles[0] = sock_stream.get_handle();
while (true) {
int ret = WaitForMultipleObjects(handlesCount, handles, false, timeoutMs);
std::cout << "Result: " << ret << std::endl;
But the WaitForMultipleObjects() returns immediately the socket stream index, indicating that its ready (it prints 0 in an endless loop).
The socket is accepted via a ACE_SOCK_Acceptor
(ACE_SOCK_Acceptor->accept()).
How do I make WaitForMultipleObjects() wait until the socket has data to read?