Windows 中的 AF_UNIX
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3872558/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
AF_UNIX in windows
提问by Arpit
I have an application that I wish to use over windows. I am using AF_UNIX family un windows. I wish to know that AF_UNIX family is available in windows. If not then is there any alternate to AF_UNIX ?
我有一个希望在 Windows 上使用的应用程序。我正在使用 AF_UNIX 系列 un windows。我想知道 AF_UNIX 系列在 windows 中可用。如果没有,那么有没有替代 AF_UNIX 的方法?
Thanks Arpit
谢谢阿皮特
回答by Prof. Falken contract breached
Edit: since about 2018, Windows 10 supports AF_UNIX.
编辑:大约从 2018 年开始,Windows 10 支持 AF_UNIX。
https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/
https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/
Old answer:
旧答案:
Just use TCP sockets, they behave very much like UNIX sockets.
只需使用 TCP 套接字,它们的行为与 UNIX 套接字非常相似。
Or you can use named pipes and use WaitForMultipleObjects()instead of select()or poll(). Windows named pipes are not quite like named pipes in UNIX. Windows named pipes are bi-directional and thus more like AF_UNIX sockets than named pipes in UNIX.
或者您可以使用命名管道并使用WaitForMultipleObjects()代替select()或poll()。Windows 命名管道与 UNIX 中的命名管道不太一样。Windows 命名管道是双向的,因此更像 AF_UNIX 套接字而不是 UNIX 中的命名管道。
回答by ExE Boss
Update:
更新:
Windows 10now finally supports this ever since the Windows 10 April 2018update was released:
自从Windows 10 April 2018更新发布以来,Windows 10现在终于支持这一点:
回答by AndiDog
Windows does not support Unix domain sockets, nor does it provide a good alternative that uses the socket API. You should use TCP sockets on Windows - bind the server to localhost if you want something similar to AF_UNIX sockets. Depending on your problem, the overhead of TCP is negligible.
Windows 不支持 Unix 域套接字,也没有提供使用套接字 API 的良好替代方案。您应该在 Windows 上使用 TCP 套接字 - 如果您想要类似于 AF_UNIX 套接字的内容,请将服务器绑定到本地主机。根据您的问题,TCP 的开销可以忽略不计。

