插座之间的管道 [英] Pipe between sockets
问题描述
我有一个充当镜像的C ++服务器.进入的东西进入另一个插座.现在,它将套接字读取到缓冲区中,然后将其写入另一个套接字.我想提高吞吐量.
I've got a C++ server that acts as a mirror. What gets in gets out to a different socket. Right now, it reads the socket into a buffer and writes it into the other socket. I want to improve the throughput.
我已经阅读了有关sendfile()
和splice()
的内容,但是似乎仅限于文件到套接字"传输.也许在套接字之间使用简单的pipe()
即可.您有什么建议?
I've read stuff about sendfile()
and splice()
, but it seems limited to "file-to-socket" transfers. Maybe a simple pipe()
between sockets would work. What do you recommend?
一个便携式解决方案将是完美的,但是如果它仅适用于Linux,那就很好了.
A portable solution would be perfect, but it's fine if it's Linux-only.
推荐答案
您可以在linux中设置命名管道.多个进程可以从中读取/写入.查看此链接: http://www.cs.fredonia.edu/zubairi/s2k2/csit431/more_pipes.html .
You can setup a named pipe in linux. Multiple processes could read/write from this. Check out this link: http://www.cs.fredonia.edu/zubairi/s2k2/csit431/more_pipes.html.
也如上所述,使用netcat应该可以解决问题(http://netcat.sourceforge.net/).
Also as mentioned above using netcat should do the trick (http://netcat.sourceforge.net/).
这篇关于插座之间的管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!