tags:

views:

105

answers:

1

We have a application which uses ReadFile to read a socket . In one of the scenarios the ReadFile gets a call saying that there are 2 bytes to read , but when the ReadFile tries to read this it return with bytesread as 0 . Does this mean that the socket on the other end has closed down ? . I mean does it necessarily mean that the socket on the other end has closed down when ReadFile reads 0 bytes ? . or could it be a error ?

A: 

When ReadFile() finds that there're two bytes to read, it at the same time does read these two bytes and they are removed from the socket. If the sender doesn't send more data, the next call will show that there's nothing to read. To determine if an error occured you have to check the retun value of ReadFile().

sharptooth