如何“管道”或“链”一个服务器套接字的输出到另一个服务器套接字的输入,类似于sendfile?
在Linux中,使用sendfile可以直接将文件传输到套接字。
但是假设我们有两个服务器套接字,我们希望第一个服务器套接字的输出发送到第二个服务器套接字。
怎么做呢? 而不是
data=sock1.read()
sock2.write(data)
In Linux, using sendfile you can directly transfer file out to a socket.
But let's say we have two server socket, we want to the output of the first one to go out to the second one.
How to do that?
Instead of
data=sock1.read()
sock2.write(data)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信 dup2 会起作用
I believe dup2 will work