1

代码服务器我有服务器监听端口 1450:

//使用UDP套接字

  clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            EndPoint ourEP = new IPEndPoint(IPAddress.Any, 1450);
            //Listen asynchronously on port 1450 for coming messages (Invite, Bye, etc).
            clientSocket.Bind(ourEP);
            //Receive data from any IP.
            EndPoint remoteEP = (EndPoint)(new IPEndPoint(IPAddress.Any, 0));

            byteData = new byte[1024];
            //Receive data asynchornously.
            clientSocket.BeginReceiveFrom(byteData,
                                       0, byteData.Length,
                                       SocketFlags.None,
                                       ref remoteEP,
                                       new AsyncCallback(OnReceive),
                                       null);

但未打开端口 1450 和客户端连接的代码:

  otherPartyIP = new IPEndPoint(IPAddress.Parse(txtCallToIP.Text), 1450);
                otherPartyEP = (EndPoint)otherPartyIP;

当我在局域网中运行代码客户端和服务器时,一切正常。但是通过网络运行我检查了局域网中的端口 1450 未打开。告诉我如何在代码服务器中打开端口 1450?谢谢

4

0 回答 0