c++ Windows 上通过 Streambuf 进行 IPC
我有一个序列化为二进制数据流的消息对象(它可以是任何 std::streambuf),我想将其传输到另一个进程。关键是,服务器应用程序必须处理许多客户端,连接必须是异步的(因为有多个客户端)和双向的(在幕后它可能由两个单独的连接实现)。消息的长度可变,应该排队。我应该为此选择什么 IPC 方法?有没有什么简单的方法可以通过应用程序传输流缓冲区?速度并不重要,但最好不要阻止应用程序太长时间。任何事情都将在 Windows 下本地完成(我的目标是 XP 和更新版本),不需要网络支持。
我还需要能够监听传入的连接。服务器应该自动检测新连接,进行一些握手并接受(如果兼容)。我知道我需要自己写下我提到的许多事情。无论如何,它必须是可能实现的,但当然越简单越好。
I have a message object serialized as binary data stream (it can be any std::streambuf), and i want to transfer it to another process. The key is, server application must handle many clients, connection have to be asynchronous (because of multiple clients), and bidirectional (under the hood it may be implemented by two separated connections). Messages have variable length and should be queued. What method of IPC should i pick for this? Is there any simple way to transfer stream buffer through applications? Speed is not critical, but it will be good not to block application for too much time. Anything will be done locally under Windows (i aim to XP and newer), no network support required.
I also need a possibility of listening to incoming connections. Server should automatically detect new connections, do some handshake and accept, if it is compatible. I am aware of that i need to write many of things i mentioned on my own. Anyway, it must be possible to achieve but of course simpler is better.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 Windows 中使用命名管道。
请参阅 MSDN 参考:http://msdn.microsoft .com/en-us/library/aa365150%28v=vs.85%29.aspx
也可以将其设置为全双工(双向)和异步。如果您熟悉 Windows 上的文件 I/O API,那么它应该很容易使用。
You can use named pipes in windows.
See MSDN ref: http://msdn.microsoft.com/en-us/library/aa365150%28v=vs.85%29.aspx
You can also set it to be full duplex (bi-directional) and asynchronous. If you are familiar with File I/O APIs on windows then it should be straightforward to use.