title: How to connect two computer on Internet using Sockets in C#
body: <p>I want to send data from PC-01 to PC-B, two computer connected on internet. Is it possible to write socket program in c#? I try to search lot, all most example on local computer or using static ip address.</p>
  
  <p><strong>Computer 1</strong> -> Internet Service Provider (having IP: 116.203.188.231) -> Broadband Router -> PC-01/PC-02</p>
  
  <p><strong>Computer 2</strong> -> Internet Service Provider (having IP: 49.202.72.175) -> Broadband Router -> PC-A/PC-B</p>
  
  <p>I try this:</p>
  
  <p>On server:</p>
  
  <pre><code>m_socListener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  IPEndPoint ipLocal = new IPEndPoint(IPAddress.Any, 8000);
  m_socListener.Bind(ipLocal);
  m_socListener.Listen(4);
  m_socListener.BeginAccept(new AsyncCallback(OnClientConnect), null);
  </code></pre>
  
  <p>On Client:</p>
  
  <pre><code>m_socClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  IPAddress ip = IPAddress.Parse(49.202.72.175);
  int iPortNo = System.Convert.ToInt32(8000);
  IPEndPoint ipEnd = new IPEndPoint(ip.Address, iPortNo);
  m_socClient.Connect(ipEnd);
  EnableCommands(false);
  //watching for data
  </code></pre>
  
  <p>Above code have no problem, but it is not working. When trying to connect it saying "No connection could be made because the target machine actively refused it".</p>
  
  <p>I checked firewall and allow the application &amp; port for both system.</p>
  
  <p>IP of connecting computer is: 116.203.188.231 and IP of another computer is 49.202.72.175. The IP 49.202.72.175 is provided by ISP (it is not static ip and also this may share by other user from isp's end) and also more than computer connected to internet through 49.202.72.175 using local lan. So can I connect the computer using socket? Or is there any technology to connect two computer?</p>
  
  <p>Thanks in advance. </p>