How can I "interconnect" two sockets in Linux?

Posted by Vi on Stack Overflow See other posts from Stack Overflow or by Vi
Published on 2010-04-20T17:29:03Z Indexed on 2010/04/20 17:33 UTC
Read the original article Hit count: 212

Filed under:
|
|

There are two connected sockets. How can I interconnect them?

  1. Data appeared on the one socket should be written to the other.
  2. EOF/FIN should propogate well. If one is half-closed, the other should also be half-closed.
int client = get_connected_client_socket();
int proxy = get_connected_proxy_socket();
negotiate_with_proxy(proxy);
iterconnect(client, proxy); 
// Now forgot about both client and proxy. 
// System should handle IO/shutdown/close. 
// Ideally even without any support of the user-space process.

Can Linux do it? Can it be done by tricking connection tracking to change tracking status of existing connection?

@related http://stackoverflow.com/questions/2673975/determine-how-much-can-i-write-into-a-filehandle-copying-data-from-one-fh-to-the

© Stack Overflow or respective owner

Related posts about linux

Related posts about sockets