-
-
Notifications
You must be signed in to change notification settings - Fork 30.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
Enable AF_UNIX support in Windows #77589
Comments
Unix socket (AF_UNIX) is now avalible in Windows 10 (April 2018 Update). Please add Python support for it. |
I've been asked by my team to investigate what is required to enable AF_UNIX in Python. Is anyone else actively investigating this? I did a prelinary investigation and the impact on test in test_sockets was pretty simple. However there were 26 test failures in test_asyncio tests, with only the naive changes to all AF_UNIX to work with the socket class on Windows. The first failure I looked at was caused by ProactorEventLoop in windows_events.py not providing a windows-specific version of create_unix_server. This results in the code falling back to AbstractServer.create_unix_server which raises NotImplementedError. |
Have you upgraded the building SDK that supports AF_UNIX? And should remove AF_UNIX flag at runtime on systems older than Windows 10 1804, see bpo-32394. |
It would be nice to investigate the habit of using AF_UNIX in Python code on GitHub: If adding this flag will break a lot of code, due to lacking supports to datagram, maybe we should not add AF_UNIX at once, and waiting for full support to AF_UNIX. |
I don't know if datagram support is coming to AF_UNIX on Windows. The changes will only add the flag on Windows, and will enable stream sockets to use AF_UNIX on Windows. In mind this isn't breaking datagram support. It is true that it's a subset of what appears to be supported on Linux/Unix. |
Most of those examples would break today if run on Windows, though (AttributeError). So they'd just continue to break, probably with a different error (I'm not clear what happens if we specify SOCK_DGRAM with this change). Having an undocumented field doesn't really help much - what we want is a documented field with a different name, perhaps WIN_AF_UNIX? (I think we need to keep the "AF_" prefix for real values and not mess up the namespace ourselves.) That way we can document that it matches AF_UNIX when defined on Windows, but will not trigger existing code that checks for the presence of AF_UNIX. Then we'll have to update the standard library to use either/both values where supported. |
If you try to create a datagram socket with the current AF_UNIX changes on Windows the error is: OSError: [WinError 10047] An address incompatible with the requested protocol was used All of the examples given will fail to load with AttributeError on Windows because socket.AF_UNIX is not a valid attribute on Windows. I think it's possible that there is code that detects whether AF_UNIX is an attribute on socket or not and does something different on Windows, but I haven't seen an example of it so far. I can make the changes to WIN_AF_UNIX when I continue working on this, just in case there is portable code out there somewhere. |
One of the test suites linked above had a skipUnless(hasattr(socket, 'AF_UNIX')) on the whole class, and at least one test assumed that it could use datagram support, so there's the example. |
Python on Windows does not support the AF_UNIX socket type yet. python/cpython#77589
Python on Windows does not support the AF_UNIX socket type yet. python/cpython#77589
Python on Windows does not support the AF_UNIX socket type yet. python/cpython#77589
Python on Windows does not support the AF_UNIX socket type yet. python/cpython#77589
Python on Windows does not support the AF_UNIX socket type yet. python/cpython#77589
This was really surprising to me. I have a native app that exposes a unix domain socket on windows for IPC, and wanted to write a Python client for it, only to find that the default socket interface does not allow using the AF_UNIX family on windows. Is there a 3rd party library that can work around this? |
@paulmon did you have any luck with this? |
This work wasn't completed because datagram support for AF_UNIX sockets on windows didn't exist when I made the original pull request. I did a quick search and I don't think that has changed. See this blog for more info about AF_UNIX support (not sure if the info is current or not) : https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/ |
From what I understand, datagram support for AF_UNIX on windows is not planned. SOCK_STREAM is the only supported mode, but that's obviously already very useful in practice. |
Any update on this? |
This issue stems from that blog post: https://blogs.msdn.microsoft.com/commandline/2017/12/19/af_unix-comes-to-windows/ Overall, 2260 days after that blog post, as far as I know:
At this stage, and unless Microsoft publishes a new shiny blog post expressing their firm intent to further develop AF_UNIX sockets in their operating system, it seems fair to "time out" and proceed with an ad-hoc implementation. I do not have any strong opinion regarding |
AF_UNIX+SOCK_STREAM would let dbus-next talk to the freedesktop reference server over a UDS like other clients. I believe all of the identification options would work fine there. |
I have a similar issue, did you find a solution? |
Theoretically, it should be possible to leverage ctypes[1] to reach the WinSock API and create AF_UNIX sockets. But I doubt the resulting socket could ever be shoehorned back into the socket module, meaning all other operations (send, receive, close, ...) would need to be done through ctypes+WinSock too. This is presumably a steep price compared to most practical applications. [1] -- correct me if I am wrong but it seems the PyWin32 project does not expose the WinSock API. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: