Transferring data between two network sockets on Windows
-
Given two network sockets, what is the most efficient way to transfer data from one to the other without touching the content in any way?
-
Is there a way (syscall APIs) to manage socket-to-socket data channels in kernel space similar to what
splice
Linux provides ? This is how I use itsplice
in Haskell at the moment: Using the GNU / Linux `splice` system call to pass Socket to Socket data in Haskell .
source to share
The zero-copy API on Windows is called TransmitFile. It reads a file descriptor and writes a socket - it is usually used to serve static files from a web server. I think you can put the socket descriptor as the file descriptor as you usually can, even on Windows. If so, this should fix your problem. I'm not sure because I haven't tried it and the docs are not explicit on the matter. It's a zero-copy API, so if it doesn't work, uh, well, of course it should.
source to share