1

stunserver のリモート コンピューターを 2 つ使用してデータを送信できません。データはローカル コンピューターから取得されますが、リモート コンピューターのデータは取得されません。

私は自分のプログラム、スタンサーバーを使用しています

public void run() 
{
    UpdateText("Now Listening..");
    remoteSender = new IPEndPoint(IPAddress.Any, 0);
    tempRemoteEP = (EndPoint)remoteSender;
    byte[] packet = new byte[1024];
    while (true)
    {
        if (socket.Available > 0)
        {
            this.nbBytesRx = socket.ReceiveFrom(packet, ref tempRemoteEP);
            nbPackets++;
            seqNo = BitConverter.ToInt16(packet, 0);
            UpdateText(nbPackets.ToString() + ":" + seqNo.ToString() + " / ");
        }
    }
}

Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,  ProtocolType.Udp);

socket.Bind(new IPEndPoint(IPAddress.Any, 0));
string localEP = socket.LocalEndPoint.ToString();
string publicEP = "";
string netType = "";
STUN_Result result = STUN_Client.Query("stunserver.org", 3478, socket);
netType = result.NetType.ToString();
if (result.NetType != STUN_NetType.UdpBlocked)
{
    publicEP = result.PublicEndPoint.ToString();
}
else
{
    publicEP = "";
}
UpdateText("Local EP:" + localEP);
UpdateText("Public EP:" + publicEP);

ThreadStart startMethod = new ThreadStart(this.run);
thread = new Thread(startMethod);
thread.Start();
4

2 に答える 2

0

私は同じ問題を抱えていました... Windowsファイアウォールを無効にして解決しました。すべてのトラフィックをブロックしていました。

于 2017-09-23T10:56:44.440 に答える