Skip to content

Conversation

andrewauclair
Copy link
Contributor

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.

Copy link
Member

@aleks-f aleks-f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally don't like just querying for something throwing an exception.

I would prefer available remaining as is, and instead document that negative value means invalid socket and fix all the affected code to take that into account (this may be an exception where it makes sense).

@andrewauclair
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants