title: Peer-to-peer behind the NATs using C#
body: <p>I have a general question that was probably answered somewhere here, but using search was not very productive. So, I will reask and if there's a thread about that, please point me there. Thanks.</p>
  
  <p>So, the general idea is:
  We have two .NET-written clients that want to talk to each other without routing the whole traffic through the server. Even more, it is not necessary for both clients to be .NET based, but one will be in any case (another can be Objective-C, C++ on Unix etc.).</p>
  
  <p>The idea is:</p>
  
  <ol>
  <li>The first client establishes the connection to some server so NAT remembers that the client is on address 10.0.0.1:1234 and the server is on address 70.0.0.7:4567. So, when the 70.0.0.7 will send the packet back to NAT, the NAT will know how to masquerade it to client.</li>
  <li>The second client establishes the connection to the same server so second NAT also remembers that the internal client on address 192.168.0.1:19234 is connected to server on address 70.0.0.7:7654 and will also be able to accept packets back for 192.168.0.1:19234</li>
  <li>Now we need to make the connection from 10.0.0.1:1234 to 192.168.0.1:19234.</li>
  </ol>
  
  <p>Both c# clients can know about endpoints of each other (let's say the server keeps the NATted addresses and they are: Client1 - 111.0.0.1:1111 and the Client2 - 222.0.0.2:2222).
  What is necessary is - for Client1 to be able to send the packets directly to 222.0.0.2:2222 without calling Socket.Connect fist and for Client2 send packets to 111.0.0.1:1111 without calling Socket.Connect as well.</p>
  
  <p>Is that possible to do with a .NET only without using any special libraries just using standard sockets etc.?</p>