-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Reintroduce Socket.DuplicateAndClose() on Windows #1760
Comments
Are you able use existing state to do this? E.g. checking if the socket has a ThreadPoolBoundHandle.
I don't know how unlikely this is. If we wanted to enable this scenario, what would we need to do? |
Yes, SafeSocketHandle.IOCPBoundHandle is the
The problem is logically similar to dotnet/corefx#42609. Instead of throwing in |
It's similar in that you'd get fast-failure, but dissimilar in that using sync APIs on a socket that has been duplicated is a valid use.
Can we prototype what this would look like? What I'm thinking is that users of |
@scalablecory looks like it's possible to detect the specific case. I will throw |
* reimplement socket duplication, fix #1760 * additional cleanup * ungroup PNSE tests, no RemoteExecutor timeout * address review findings * fix path for Interop.WSADuplicateSocket.cs * remove swallowing in Socket(SocketInformation) * review suggestions * make sure duplicate socket is not inheritable * remove debug code leftover * harden SocketPal.CreateSocket() * blittable WSAPROTOCOL_INFOW * additional naming fixes, default System.Net.Sockets.sln configurations to Windows_NT again * disposal on errors, improve comments, more tests * nits * handle GetSockName() error
In Framework we had DuplicateAndClose and a matching
Socket(SocketInformation)
constructor to allow transferring sockets to other Win32 processes..NET Core does not support this method because of the reasons described in the linked comments.
Upon the request of two internal partners we propose to reintroduce a constrained implementation with the following limitations/differences:
SocketInformation
API-s is strongly specific to that platform.DuplicateAndClose
.Proposal for preventing invalid usages
It's not possible to use asynchronous operations in both the original and the duplicate socket because of platform limitations in IOCP.
Framework behavior
[EDIT] New propsal
[EDIT] Original proposal
The downside of this design would be that we would prevent cloning a socket (previously used asynchronously) to be used for synchronous operations after being cloned. This is a very unlikely scenario though.
The text was updated successfully, but these errors were encountered: