C++ 应用程序:是否可以将接受的 TCP 连接从一个进程传递到另一个进程? [英] C++ application: Is it possible to pass accepted TCP connection from one process to another?

查看:25
本文介绍了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 连接从一个进程传递到另一个进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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