title: Pass tcp connection to different computer as a paramter
body: <p>I been trying to learn the TCP protocol. so I am able to transfer data between two computers on the same network as:</p>
  
  <pre><code>\\the server:
  
  var server = new TcpListener(ipAddress, port); //create a server
  server.Start(); //start the server
  
  //wait here until a client get's connected to this computer
  TcpClient someClient = server.AcceptTcpClient();
  
  NetworkStream stream = someClient.GetStream(); \\create a network stream object in order to read and send data to the other connected computer
  </code></pre>
  
  <p>once the server is running, the client application will be able to connect to the server as:</p>
  
  <pre><code>//Client:
  var client = new TcpClient(serverIP, port);
  NetworkStream stream = client.GetStream();
  //initialize data to by some byte array. the data you wish to send
  stream.Write(data, 0, data.Length);
  
  
  
  byte[] bytes = new bytes[1000] //instantiate a byte array
  connection.stream.Read(bytes, 0, bytes.Length)  // wait here until data is send 
  
  // in this line data has been received and it will be placed the bytes array
  </code></pre>
  
  <p>I label each node with a different letter. for example  note how computer A and computer C happen to be on the same network:</p>
  
  <p><img src="https://i.stack.imgur.com/fdPOZ.png" alt="enter image description here"></p>
  
  <p>Hope this picture helps me explain what I mean. </p>
  
  <h2>Establish connection between computer A and C:</h2>
  
  <p>If I want to establish a connection between computer A and C then that will probably be the easiest case. In other words I will not have to do any kind of port forwarding in order to establish the connection.</p>
  
  <h2>Establish connection between computer A and server S:</h2>
  
  <p>if the client computer happens to be computer A and the server computer happens to be computer S then computer A will be able to find server S. So this connection should be simple too.</p>
  
  <h2>Establish connection between computer A and computer B:  (here is my problem)</h2>
  
  <p>So if computer A wants to find computer B then router Y will have to forward all traffic from port 'somePort P' to computer B and A will have to provide the ip address of router Y or the WAN ip address. </p>
  
  <h2>Until this point my title question should not make sense let me explain what I mean when I say "Pass tcp connection to different computer"</h2>
  
  <p>I actually need to establish a connection between computer A and computer B without having to configure the routers. I been thinking a lot and I think this should be possible: (it's a little crazy though)</p>
  
  <p>if you remember from my previous code once the connection was established, everything that was send/written through the network stream is received by the other end of the connection. so because computer A is not able to connect to computer B then make A connect to the server S. So far there is a connection between computer A and server S. Ok now establish a tcp connection between computer B and server S. by now the server S should have two distinct tcp connections, one to computer A and the other to computer B.</p>
  
  <p>Because the server has two distinct tcp connections it should have also two NetworkStream objects. let's say that the tcp connection between server S and computer A has the object <code>NetworkStream streamA;</code> and the tcp connection with computer B has the object <code>NetworkStream streamB;</code></p>
  
  <h2>So here comes the crazy part. The server S serializes the instantiated and working object streamB and sends that object to computer A. then computer A deserializes that object and cast it to a NetworkStream object. Computer A should now have a copy of object streamB. WHAT WILL HAPPEN IF THEN YOU SEND DATA THROUGH OUT THAT STREAM!? theorically computer B should receive the data I think. I mean maybe I will have to modify each package header information so that router Y treats those packages as if they where coming from Server S!</h2>
  
  <p>the reason why I want to do this is because I have created a server application and client application where it will sync files between two computers on a specific folder. a lot of times users using this program do not know how to enable port forwarding. I also know I may be able to solve this using what is called as "tcp puch holing" but I have not been able to find a working method on c#....</p>