How to stop a blocking call of WSAPoll

1.3k views Asked by At

I have a case to handle. There is one thread calling WSAPoll() to receive data from TCP connection. The code looks like this:

int result = WSAPoll(fdSocket, 1, timeout);
if (result == 0)
{
    // time out
}
else if (result == -1)
{
    // socket error
}

If I set timeout to be a negative number, the thread will wait indefinitely. However, I want to make this function return a value, such as 0, directly to this thread if I call a function StopWait() from another thread.

So what can I do to make this work? Add an asynchronous procedure call to this blocking thread through function StopWait() bu the other thread? If it is, what to add can make it return the value I want?

Thanks!

0

There are 0 answers