Sockets – Joining 2 Sockets

socketssystem

Is it possible to join two sockets?

For example, if a process is acting as a router of messages between 2 other processes at some point being able to step aside would save a bunch of socket IO. This seems like it should be possible, but I've never even HEARD of it being done!

If it is possible, is it possible on Linux AND Windows? If so, are different mechanisms used to set this up?

BTW: I just found this:

Linux splice() system call.

This seems close to what I am asking for (assuming of course this works on socket FD's as well), but is there a Windows equivalent?

Best Solution

AFAIK, It is not possible.

A simple example: If your processes runs on three different machines, how could the proxy machine step aside without involving traffic redirection at TCP/UDP/whatever level?

splice is not a solution, it simply optimizes the i/o transfer avoiding unnecessary memory copies but, in any case, you need a process that cycles on input and call splice to "transfer" data to output (and if the sockets are real network sockets, the data have to pass twice through the network card).

LLP, Andrea

Related Question