No connection can be made because the target machine actively rejects it

I am working on a simple TCP / IP application server for greeting in C # and cannot connect my client. Can anyone suggest any additional troubleshooting steps? I'm running out of ideas ...

Here are the relevant sections of the code:

Server:

Console.Out.WriteLine("About to bind address");
IPAddress ipAd = IPAddress.Parse("127.0.0.1"); 
Console.Out.WriteLine("Choose a port to bind...");

String port = Console.In.ReadLine();
int iPort = Int32.Parse(port);

TcpListener myList = new TcpListener(ipAd, iPort);

myList.Start();

Console.WriteLine("The server is running at: "+myList.LocalEndpoint);
Console.WriteLine("Waiting for a connection.....");

Socket s = myList.AcceptSocket();
Console.WriteLine("Connection accepted from " + s.RemoteEndPoint);

customer:

Console.Out.WriteLine("enter address: ");
string address = Console.In.ReadLine();
Console.Out.WriteLine("enter port: ");
int port = Convert.ToInt32(Console.In.ReadLine());

TcpClient tcpclnt = new TcpClient();
Console.WriteLine("Connecting.....");

Console.Out.WriteLine("Address: " + address + ":" + port);
tcpclnt.Connect(address, port);

I can ping the server from the client machine, however I cannot connect to the server using the connected port. I tried various ports (several in low 8000 and several in about 40,000). I disabled Windows Firewall on both systems. Systems are connected to a router that is not on the Internet. I tried with and without port forwarding to forward incoming requests to this port to the server machine without effect.

, , :

, .

InnerException, , - . ?

, - .

!

+3
5

, . , .

, , ? 192.168.x.x 10.x.x.x

+5

. 0.0.0.0, 127.0.0.1. 127.0.0.1, localhost. 0.0.0.0 .

nmap - , .

: IP- , . 0.0.0.0, . USB-, VPN-.

+9

netstat -al ( Windows Unix) ,

+3
source

Why don't you use remote .NET? This is better than running a TCP / IP client server. You can transfer messages between objects.

+1
source

Did you try to start the client server on the same computer to make sure the connection is completed first? In addition, try using the assigned router or the static IP address of the machine on which the server is running, and binding to loopback.

+1
source

Source: https://habr.com/ru/post/1703194/


All Articles