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.
Computer 1 -> Internet Service Provider (having IP: 116.203.188.231) -> Broadband Router -> PC-01/PC-02
Computer 2 -> Internet Service Provider (having IP: 49.202.72.175) -> Broadband Router -> PC-A/PC-B
I try this:
On server:
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);
On Client:
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
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".
I checked firewall and allow the application & port for both system.
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?
Thanks in advance.