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.
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Socket编程 TCP方式发送时间有点长
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
On Windows, use
WSADuplicateSocket
, pass the filled inWSAPROTOCOL_INFO
to the other process, useWSPSocket
to recreate a socket.On unix-like OS'es this is possible using the
sendmsg()
system call. libancillary abstracts this for you.In Unix, a TCP connection is represented as a socket file descriptor. When you
fork
a process, the file descriptors are inherited by the child process, including TCP sockets. (Though they may be closed onexec
if given theFD_CLOEXEC
flag withfcntl
.)It's also possible to transfer file descriptors between unrelated processes using a local (Unix) domain socket; see this question.
I'm not sure about Windows.