C++ application: Is it possible to pass accepted TCP connection from one process to another?

后端 未结 2 491
礼貌的吻别
礼貌的吻别 2020-12-19 08:50

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 w

2条回答
  •  盖世英雄少女心
    2020-12-19 09:26

    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 on exec if given the FD_CLOEXEC flag with fcntl.)

    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.

提交回复
热议问题