-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Socket.Select() method doesn't work as expected on macOS #920
Comments
It seems like we use poll() system calls returns immediately with 0 and no events even if infinite (or long) time is specified. While this looks like system bug we can either use select() on OSX or use kqueue under the cover. from OSX man page: It seems like there is option to avoid limits we were trying to workaround in first place. |
Looks like most people are using async for these scenarios. Only 1 complaint so far. Compat angle: It works on other platforms. |
This might be fairly straightforward. |
Is there any update on this issue? When I run the above snippet in dotnet 6.0.102 on macOS the Select call hangs. If I compile the same code using mono it works as expected. Happy to provide more info if that'd help. |
triage: we should document that there are OS behavior differences. And perhaps re-test it on recent macOS versions. |
Is there any update on this issue? |
9 is probably earliest. Even if we have fix soon I don't think this would qualify for servicing @maxstue-exx |
I did some testing with plain C and the outcome is interesting. struct pollfd polls[2];
polls[0].fd = sockfd;
polls[0].events = POLLIN | POLLHUP ;
polls[1].fd = sockfd;
polls[1].events = POLLPRI;
int err = poll(&polls, 2, 1000); fails the way described above e.g. the `poll' will never notice there are data available to read. But this works as expected struct pollfd polls[1];
polls[0].fd = sockfd;
polls[0].events = POLLIN | POLLHUP | POLLPRI;
int err = poll(&polls, 1, 1000); so it seems like Darwin kernel does not like repeating descriptors in the array. So we can rearrange the code to merge Any preference here @stephentoub? The merging will add some expense but I would not expect people to use select with huge number of sockets. Regardless of this issue, it does not scale well anyway. from the c# API, can you avoild using the |
Did you mean
I'd opt to specialize an answer for the affected platforms rather than make the others worse perf-wise. And then I'd opt to do whichever is easiest in the macOS specialization, as this doesn't seem like something likely to be super hot path, especially if it only manifests when providing a non-empty error list. |
yes, I meant |
On macOS,
Socket.Select
method doesn't work as expected. In .NET Framework, it works as expected.Expected result:
The following output is written to stdout:
Actual result:
The following output is written to stdout:
Dotnet Info
The text was updated successfully, but these errors were encountered: