Question

I have a question

How to know if a client didn't respond to the server during a specified time ?!

I am using threading not select function.

your help will be greatly appreciated :)

Thank you.

Was it helpful?

Solution

You would need to look into [setting the socket option][1] as follows:

setsockopt(sockid, SOL_SOCKET, SO_RCVTIMEO,(char *)&tv,sizeof(struct timeval));

Having that done, you can check againt SOCKET_ERROR when calling the receive and/or send functions. The specific error code can be obtained by calling WSAGetLastError.

This is one of those potential error codes:

WSAEWOULDBLOCK 10035

Resource temporarily unavailable.

This error is returned from operations on nonblocking sockets that cannot be completed immediately, for example recv when no data is queued to be read from the socket. It is a nonfatal error, and the operation should be retried later. It is normal for WSAEWOULDBLOCK to be reported as the result from calling connect on a nonblocking SOCK_STREAM socket, since some time must elapse for the connection to be established.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top