Connection failed because the destination computer rejected the connection request 127.0.0.1: 11000

Client-server application on tcp / ip

Everything worked on win xp (ports 11000 and 11001), but it doesn't start on win7.

So:

  1. We tried disabling the firewall;
  2. We tried to connect to the open ports
  3. The server is running(another program - a simple client-server on tcp plows), but this one is not

        // Устанавливаем для сокета локальную конечную точку
        IPHostEntry ipHost = Dns.GetHostEntry("127.0.0.1");
        IPAddress ipAddr = ipHost.AddressList[0];
        IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, int.Parse(textBox1.Text)); 
    

    enter a description of the image here

If anyone will suggest an idea, I will be very grateful. The problem is often it occurs, but no one has given a solution

Author: Grundy, 2018-12-02

2 answers

Why do you use Dns to convert 127.0.0.1 to an ip address? You didn't find an easier way?

For starters, the IPAddress class has a wonderful method Parse:

IPAddress ipAddr = IPAddress.Parse("127.0.0.1");

In addition, this class has a static field Loopback:

IPAddress ipAddr = IPAddress.Loopback;
 1
Author: Pavel Mayorov, 2018-12-03 06:25:51

You need to start receiving data.

Private Sub Getfile() listener1 = New TcpListener(IPAddress.Any, 27020) listener1.Start() While True Dim client As TcpClient = New TcpClient() client = listener1.AcceptTcpClient() Dim Stream As NetworkStream = client.GetStream() Dim reader As BinaryReader = New BinaryReader(Stream) Dim fileLength As Integer = reader.ReadInt32 Dim fileData() As Byte = reader.ReadBytes(fileLength) Dim Str As String = Encoding.Default.GetString(fileData) STR1 = Str End While End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Th = New System.Threading.Thread(AddressOf Getfile)
    Th.Start()
End Sub

VB syntax.

 -1
Author: Николай, 2019-12-26 17:22:15