-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Remove received bytes length check #100619
Conversation
Tagging subscribers to this area: @dotnet/ncl |
This comment was marked as resolved.
This comment was marked as resolved.
I think only the case of 65536 bytes received got changed. Generally this PR just removes the |
Ignore my previous comment, I got confused what's happening here, since I was only looking at the changed codeblocks 😞 The change basically removes an "optimization" for the Unfortunately the test cases in |
Updated tests. Some tests are skipped for my Mac. Hope everything is fine. |
Is there particular functional issue you are trying to fix @skyoxZ? While I do no know why the code exist as it is but I would assume it was put in for some reason. I really wish we could obsolete UDPClient but it is legacy API and and I'm not sure it is worth of touching. |
No, just found it when reading the code.
I don’t think UDPClient is not recommended any more. It just works without any particular issue (a negative example is SmtpClient, which doesn’t work in many real-world cases). I’m confident of my proposal but there’s a risk that my codes may have bug. Feel free to close the PR if you prefer to do so. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I do no know why the code exist as it is but I would assume it was put in for some reason.
It looks like an "optimization" for the case where received == 65536
. It prevents a copy since _buffer
has the correct size in that case. Given this case is impossible or at least extremely unlikely, I see no harm from removing it.
I really wish we could obsolete UDPClient
Given it's not obsolete yet, I see value in code simplifications. IMO there is no risk from merging this PR & especially that it also adds tests. @wfurt if you have strong concerns, feel free to close the PR, otherwise I will go ahead and merge.
I'm ok if we proceed. |
* Remove received bytes length check * delete whitespace * fix typo * Improve tests * Update UdpClientTest.cs * Update UdpClientTest.cs --------- Co-authored-by: Anton Firszov <Anton.Firszov@microsoft.com>
Any packet can't be larger than 65535 bytes so it should never reach to
MaxUDPSize
(65536). Even if that happens, I don't think it's good to return_buffer
directly in case users handle the data asynchronously.