Montag, 25. Februar 2008

Socket read

A few days ago one of our customers complained that the connection loss notification did not work. To cut a long story short, the read() function still returned 0 and 0 bytes read, even though the socket was closed long ago.
Wouldn't you expect the read() function to return some kind of error after some time?
Well, luckily both client and server were running on the same system, and the pid of the server is stored in the shared memory, so the client can check if the server is still running. With this change the client detects connection losses within a matter of microseconds.

Ok, the problem is solved, but still I'd like the read() function to return an error code if the socket was closed, especially if the client and server are running on the same system?!?

Keine Kommentare: