Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为什么我的tcplistener可以';我不听。当我构建应用程序的setup.exe文件时?_C#_Multithreading_Tcplistener_Setup.exe - Fatal编程技术网

C# 为什么我的tcplistener可以';我不听。当我构建应用程序的setup.exe文件时?

C# 为什么我的tcplistener可以';我不听。当我构建应用程序的setup.exe文件时?,c#,multithreading,tcplistener,setup.exe,C#,Multithreading,Tcplistener,Setup.exe,我写了一个使用TcpListener的程序。当我的应用程序运行C#程序时,其他应用程序和其他设备可以(从其他计算机或其他设备)连接到我的应用程序,我的TcpListener可以监听并响应它们。但是,当我从我的应用程序构建setup.exe文件并安装它时,如果其他应用程序在我的计算机上运行,TcpListener可以侦听并响应,但如果其他应用程序在其他计算机上运行,TcpListener无法侦听。其他设备也无法连接到我的应用程序 请引导我解决我的问题。 谢谢 通过设置windows防火墙,我可以解

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

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


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

如果有人需要更多信息来回答我的问题,请询问。
    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();
                }
            }