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.
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?
A portable solution would be perfect, but it’s fine if it’s Linux-only.
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.
Also as mentioned above using netcat should do the trick (http://netcat.sourceforge.net/).