用于本地 IPC 的 POSIX 消息队列或 unix 域套接字
我需要在客户端和服务器之间设置本地IPC。这是单服务器多客户端的情况,需要双向交换数据。客户端是一个命令,它发送命令选项,服务器获取数据并将其发送给客户端。客户端在控制台上打印从服务器接收到的输出。
命令发送的数据很小,但服务器发送到命令的数据很大(~11Mb)。 Windows 中的现有设计使用命名管道以 65 KB 的块发送数据。服务器需要同时将数据发送到多个命令客户端,因为从不同终端同时执行具有不同选项的命令是很常见的。
我省略了 FIFO,因为来自多个进程的数据可以交织以获取大小大于 4096 字节的消息。如果我错了,请纠正我。
考虑以下两个标准,POSIX 消息队列还是 unix 域套接字哪个是更好的选择?
- 来自多个客户端的消息
- 数据的大小(65K)不应交错。客户端只能接收发送给该客户端的数据。
如果您需要更多详细信息,请告诉我。
问候, 罗希尼·钱德拉
I need to setup local IPC between client and server. It is a case of single server and multiple clients and data need to be exchanged in both directions. The client is a command which sends the command options and the server fetches the data and sends it to the client. The client prints the output received from server on the console.
The data sent from the command is small but the data sent by the server to the command is huge(~11Mb). The existing design in windows sends the data in chunks of 65 Kilobytes using named pipes. Server need to send the data to multiple command clients simultaneously as it is common to execute commands with different options at the same time from different terminals.
I have left out FIFO since the data from multiple processes can be interleaved for messages of size greater than 4096 bytes. Please correct me if I am wrong.
Considering the below two criteria, which would be a better choice, POSIX message queues or unix domain sockets?
- size(65K) of the message
- data from multiple clients should not be interleaved. Only data addressed to that client should be received by a client.
Please let me know if you need more details.
Regards, Rohini Chandra
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来你想要一个插座。使用bind在服务器上设置套接字,然后当每个客户端连接到它时,服务器可以fork来单独处理每个客户端,或者使用select来处理客户端。分叉通常更简单:
Sounds like you want a socket. Set up the socket on the server using bind, then when each client connects to it, the server can either fork to handle each client individually, or use select to process the clients. Forking is usually simpler: