C++ application: Is it possible to pass accepted TCP connection from one process to another?(C++ 应用程序:是否可以将接受的 TCP 连接从一个进程传递到另一个进程?)
问题描述
所以我想知道 - 是否有可能将接受的 TCP 连接(在 Windows 或 Unix 等操作系统上)从一个进程传递到另一个进程?这里的重点是传递连接 - 而不是以代理应用程序的方式传递数据.
So I wonder - is it possible to pass accepted TCP connection (on Windows or Unix like OS) from one process to another? Here the point is to pass connection - not data in a way a proxy app would.
推荐答案
在 Windows 上,使用 WSADuplicateSocket
,传入WSAPROTOCOL_INFO
到另一个进程,使用 WSPSocket
重新创建套接字.
On Windows, use WSADuplicateSocket
, pass the filled in WSAPROTOCOL_INFO
to the other process, use WSPSocket
to recreate a socket.
在类 Unix 操作系统上,这可以使用 sendmsg()
系统调用实现.libancillary 为您抽象了这一点.
On unix-like OS'es this is possible using the sendmsg()
system call. libancillary abstracts this for you.
这篇关于C++ 应用程序:是否可以将接受的 TCP 连接从一个进程传递到另一个进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C++ 应用程序:是否可以将接受的 TCP 连接从一个进程传递到另一个进程?


- 从python回调到c++的选项 2022-11-16
- C++ 协变模板 2021-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- Stroustrup 的 Simple_window.h 2022-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 静态初始化顺序失败 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 近似搜索的工作原理 2021-01-01