Reputation: 34218
Hi, I'm trying to connect my chat client to my server, but I keep getting an error. I have chat server which is running in a machine which is published in internet and it has fixed IP address and it is running on port 5001. When my chat client tries to connect to that server then I am get the error. The line which is raising error as follows
ipAddr = IPAddress.Parse(txtIp.Text);
// Start a new TCP connections to the chat server
tcpServer = new TcpClient();
tcpServer.Connect(ipAddr, 5001);
When I run both my chat client & server in my local machine with local machine IP, it works. Please tell me what I need to changes in code as a result my chat server & client both can communicate over the internet. Thanks
Upvotes: 1
Views: 2400
Reputation: 23053
Fixed IP might not be enough if it goes first through some network of computers. You might need to Forward Port if it is simple network, or if it is more complicated probably it has own direct line but have closed Ports so you have to open them through Firewall within system as well within possible hardware that can filter traffic.
It probably not the code issue at all.
As well when you create server socket, try to Bind it to IPAddress.Any, because if you bind it to specific device it might be source of problem as well.
Upvotes: 2