Your solution is close to being correct, POSIXwise. The completely
"compliant" way of doing this is
ssize_t read_return_value;
size_t nr_of_bytes_read;
...
read_return_value = read ( socket, buffer, sizeof buffer );
if ( read_return_value == -1 ) {
... /* Handle the error. */
}
nr_of_bytes_read = (size_t) read_return_value;
...
Then, nr_of_bytes_read can be dealt with in whatever way desired. I know
this is clumsy, but that is the price one pays for semantic overloading
of the return value from read. (By the way, ()s are not required around
sizeof's argument if it is a variable name -- only if it is a type
name.)
Tom Dailey