I believe this should be a int instead of uint8_t.
Same for uint_8ret.
reason: if the connection is still up but there is no data to be read, ret is set to -1. for a uint_8_t, this will result in a positive number.
Later in the same routine, if ( ret > 0 ) yield true in this case, though it is not what you would want.
Anyone please confirm if I got this right. My knowledge of C++ is still fairly limited.
lampmaker
What you are describing is a logical bug. I mean from code reading point of view it is wrong.
I'm however not sure whether the compiler will generate bad code. If not you save a byte of memory by sticking to 8 bit.
I've tried to look at the code but I can not find any socket.cpp delivered with arduino. Where did you get the code from?
lampmaker
I've double checked and indeed this is a bug.
you have perfectly understood the code.
The code will however not fail but the desired optimization will not happen.
Best regards
Jantje