3
  1. Given two network sockets, what is the most efficient way to pipe data from one to the other without touching the contents in any way?

  2. Is there a way (system call APIs) to manage socket-to-socket data piping in kernel space similar to what splice provides on Linux? This is how I use splice in Haskell at the moment: Using GNU/Linux system call `splice` for zero-copy Socket to Socket data transfers in Haskell.

Community
  • 1
  • 1
Cetin Sert
  • 4,497
  • 5
  • 38
  • 76
  • @ixe013 as sockets are managed by the kernel I would assume both are ends are in the kernel :/? – Cetin Sert Apr 10 '12 at 12:04
  • I meant the code that calls socket. In other words, is the code calling `socket()` running in kernel mode ? I don't know of such a function in Windows, but [kernel code and user code can share memory](http://www.microsoft.com/whdc/driver/kernel/mem-mgmt.mspx). But I beleive you would need to implement the kernel code yourself to take advantage of it. [User mode code has some control over the data](http://support.microsoft.com/kb/214397) is sends, but you are looking for a 'no touch' solution, so this is not an answer. – ixe013 Apr 10 '12 at 12:57
  • @ixe013 the code calling socket() is in user mode. – Cetin Sert Apr 10 '12 at 13:38

1 Answers1

1

The zero-copy API on Windows is called TransmitFile. It reads a file handle and writes a socket - it's usually used to serve static files from a web server. I think you can supply a socket handle as the file handle, since you normally can, even on Windows. If so, that should solve your problem. I'm not certain because I've not tried it and the docs aren't explicit on this point. It is the zero-copy API though, so if it doesn't work, er, well it sure oughta.

GarethR
  • 724
  • 5
  • 7