Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw Error in Socket::available if Socket Error Occurs #4539

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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