C# TCP Listen and Connect on the same Local Port
<p>I have a C# Console Application where I'm trying to implement TCP Hole Punching.</p>

<p>I need to listen on a Local Port and at the same time (simultaneously/asynchronously) connect to 2 different remote hosts (in reality a remote hosts public and private endpoints) using the same Local Port.</p>

<p>As I understand I somehow need to bind the Sockets/Ports but I can't figure this out in C#.</p>

<p>There's the TCPListener, TCPClient and Socket classes and I don't know which ones to use to accomplish what I need.</p>

<p>I'm following this guide <a href="http://www.bford.info/pub/net/p2pnat/index.html" rel="nofollow">http://www.bford.info/pub/net/p2pnat/index.html</a> Chapter 4.2</p>

<blockquote>
  <ol start="3">
  <li>From the same local TCP ports that <em>A</em> and <em>B</em> (Clients) used to register with (Server) <em>S</em>,  <em>A</em> and <em>B</em> each asynchronously make outgoing connection attempts to the other's public and private endpoints as reported by <em>S</em>, while simultaneously listening for incoming connections on their respective local TCP ports.</li>
  </ol>
</blockquote>

<p>I've already implemented the server part using NodeJS and it's working fine, I'm struggling with the Local Port stuff mentioned above.</p>