Read() time out in socket programming

Hi,
When can the read() system call gives timeout error when the same connection worked for writing data to the other end of the socket, while the next call with read() gives timeout error?

Can anyone please explain when this kind of situation appears?

Thanks,
Sanzee

I'm confused -
I am guessing you are getting the EAGAIN error.

Are there two timeout errors in a row?

Did you reconnect after the first one?

If we could see a code snippet it would help.

and which OS? as jim_mcnamara writes in most cases you receive EAGAIN error, if there is nothing to read and file descriptor is in non-blocking state.

In AIX it is possible to receive ETIMEDOUT on NFS share:

       If Network File System (NFS) is installed on the system, the read
       system call can also fail if the following is true:
       Item
            Description
       ETIMEDOUT
            The connection that is timed out.