poco
poco copied to clipboard
Throw Error in Socket::available if Socket Error Occurs
Changes to help address the issues I was seeing in #4537. This change makes SocketImpl::available throw an error exception if the result of recvfrom is negative and there was a socket error for UDP sockets. This will correctly inform the calling code that the socket is invalid and needs to be reset. This also fixes the issue with receiveBytes throwing std::bad_array_new_length because it will instead throw a Poco exception first when calling available.
I can change it back and throw exceptions in places that poco calls available. If that's what you want. I do feel that the exception forces the issue better. But I agree with your statement about querying functions.