Windows的等效AF_UNIX [英] AF_UNIX equivalent for Windows

查看:170
本文介绍了Windows的等效AF_UNIX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何使用Windows上类似Unix Domain Socket的行为.

I want to know how to use something that behaves like Unix Domain Socket on Windows.

行为是:一个进程将是一个服务器",并接收来自其他进程的连接,并且它可以像TCP套接字那样保留和使用来自不同进程的连接.

The behaviour is: A process will be a "server" and receive connections from other processes and it can keep and use connections from different processes, as a TCP socket does.

IP套接字不是解决方案,因为它需要选择一个端口,来自其他应用程序的进程可能需要选择的端口,并且打开的端口可能会出现在网络中.
我不知道命名管道是否可以接收并保留多个客户端,但是我不知道如何区分不同的客户端.而且,它没有提供通过select之类的方法等待来自多个连接的数据的方法.

IP socket is not a solution, because it requires to choose a port, processes from other applications may need the chosen port, and the open port may be seen in the network.
I do not know if named pipes can receive and keep multiple clients, but I did not see how to distinguish different clients. And it does not provide a way to wait data from multiple connections with something like select.

一个古老的问题是有关使用命名管道的问题,但并未说明如何使用命名管道来获得所需的行为. Windows中的AF_UNIX
我没有看到如何获得特定客户的服务.

An old question says about using named pipes, but it does not explain how to use named pipes to get the desired behaviour. AF_UNIX in windows
I did not see how to get the handle of a specific client.

推荐答案

我找到了答案.

最大的区别是等待连接的句柄与进行客户端通信的句柄相同.我必须为服务器创建一个新的命名管道,以等待下一个客户端.

The big difference is that the handle the waits a connection is the same that does communications to a client. I would have to create a new named pipe for the server to wait for the next client.

参考文献:
http://msdn.microsoft .com/zh-CN/library/windows/desktop/aa365799%28v = vs.85%29.aspx
http://msdn.microsoft .com/zh-CN/library/windows/desktop/aa365588%28v = vs.85%29.aspx
http://msdn.microsoft .com/en-us/library/windows/desktop/aa365603%28v = vs.85%29.aspx

References:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365799%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365588%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365603%28v=vs.85%29.aspx

这篇关于Windows的等效AF_UNIX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆