为什么我的 tcplistener 不能听。当我构建我的应用程序的 setup.exe 文件时?

why my tcplistener can't listen. when i build a setup.exe file of my app?

我写了一个使用 TcpListener 的程序。当我的应用程序 运行 使用 C# 程序时,其他应用程序和其他设备可以(从其他计算机或其他设备)连接到我的应用程序,并且我的 TcpListener 可以监听并响应它们。但是当我从我的应用程序构建一个 setup.exe 文件并安装它时,如果其他应用程序在我的计算机上 运行ning,TcpListener 可以监听和响应,但如果其他应用程序 运行ning 来自另一台计算机,TcpListener 无法收听。还有其他设备无法连接到我的应用程序。

请指导我解决我的问题。 谢谢

    TcpListener TcpListener;
    private void Form1_Load(object sender, EventArgs e)
            {
                TcpListener = new TcpListener(IPAddress.Any, 4051);
                thread = new Thread(Connection);
                thread.Start();
            }
    
    public void Connection()//accept connection
            {
                while (true)
                {
                    TcpClient tcpClient= new TcpClient();
                    TcpListener.Start();
                    tcpClient = TcpListener.AcceptTcpClient();
                        thread = new Thread(() => ConnectionFromOut(tcpClient));
                    thread.Start();
                }
            }

通过设置windows防火墙,我可以解决这个问题。