Network Programming - Applications Communication
<p>I'm developing new software and I need to be communicate those apps amongst themselves like TeamViewer and Skype. For this challenge, I'm read too many article and write code but I cannot do that. I must use TCP, it cannot be UDP. Data safety is very important for my app.</p>

<p><a href="http://www.codeproject.com/Articles/807861/Open-NAT-A-NAT-Traversal-library-for-NET-and-Mono" rel="nofollow">http://www.codeproject.com/Articles/807861/Open-NAT-A-NAT-Traversal-library-for-NET-and-Mono</a></p>

<p>I found <strong>N</strong>(etwork)<strong>A</strong>(address)<strong>T</strong>(ranslation) can solve my problem and I use it. I write same code to what they say, but still doesn't work...</p>

<p>LISTENER <strong>CLIENT</strong> CODES</p>

<pre><code>NatDiscoverer discoverer = new NatDiscoverer();
CancellationTokenSource cts = new CancellationTokenSource(5000);
NatDevice device = await discoverer.DiscoverDeviceAsync(PortMapper.Upnp, cts);

// display the NAT's IP address
Console.WriteLine("The external IP Address is: {0} ", await device.GetExternalIPAsync());

// create a new mapping in the router [external_ip:1702 -&gt; host_machine:1602]
await device.CreatePortMapAsync(new Mapping(Protocol.Tcp, 1602, 1702, "For testing"));

IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 1602);
socket = new Socket(endPoint.AddressFamily, SocketType.Stream,ProtocolType.Tcp);
socket.SetIPProtectionLevel(IPProtectionLevel.Unrestricted);
socket.Bind(endPoint);
socket.Listen(4);
</code></pre>

<p>REQUEST SENDER <strong>CLIENT</strong> CODES</p>

<pre><code>Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("100.96.106.192"), 1602);
                sock.Connect(ipep);
</code></pre>

<p>They are 2 client and I want to conenct them like that. "100.96.106.192" is computer Public IP (not a router(external) IP)..</p>

<p>For this challenge, I can use other languages or other libraries too except WCF because my app need to work <strong>platform independently</strong>. </p>

<p>For example, I start to Listener Client and into 'cmd', I write 'netstat -a' and I saw, it's listen to 0.0.0.0:1602. But Why?</p>

<p>Please help me and guide me. What's wrong my code? What am I doing wrong? How can I solve this problem? </p>

<p>Thanks for all answers and helps. Have a good day, good works...</p>