带有 STUN 的 C# RDP 应用程序 [英] C# RDP application with STUN
问题描述
我已经搜索了互联网上关于使用 C# 和 STUN 穿越 NAT 的所有链接.我获得了应用程序使用的公共 IP 和端口.在我读过的大多数网页上,STUN 是一种协议,它应该可以帮助我连接到 NAT 路由器或防火墙后面的另一个客户端.现在我的问题...如果我理解 STUN,STUN 只是在那里给我公共 IP 地址和我的 NAT 的特征.
I have searched all most all the links in the internet about NAT traversing with C# and STUN. I got the public IP and the port that is using by the application. On most webpages i've read about STUN, a protocol, which should help me to connect to another client behind a NAT-Router or a firewall. Now my question... if I understand STUN, STUN is ONLY there to give me the public IP-Address and the characterization of my NAT.
但是我如何将这些信息连接到另一个客户端?
But so HOW can I connect with this informations to another client?
这是我用我的应用程序配置 STUN 的示例http://www.codeproject.com/Articles/18492/STUN-Client
here is the example I used to configure the STUN with my application http://www.codeproject.com/Articles/18492/STUN-Client
推荐答案
这是一个 C# 实现:
Here is a c# implementation:
http://www.codeproject.com/Articles/18492/STUN-Client
示例用法:
// Create new socket for STUN client.
Socket socket = new Socket
(AddressFamily.InterNetwork,SocketType.Dgram,ProtocolType.Udp);
socket.Bind(new IPEndPoint(IPAddress.Any,0));
// Query STUN server
STUN_Result result = STUN_Client.Query("stunserver.org",3478,socket);
if(result.NetType != STUN_NetType.UdpBlocked){
// UDP blocked or !!!! bad STUN server
}
else{
IPEndPoint publicEP = result.PublicEndPoint;
// Do your stuff
}
这篇关于带有 STUN 的 C# RDP 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!