将C#UdpClient连接到代理

时间:2020-06-20 04:38:13

标签: c# proxy udp udpclient

我想在我的C#应用​​程序中添加一个代理层,该代理层连接到ip地址。我有我的代理服务器地址和端口,但是我不知道如何将其与UdpClient请求一起使用。这是代码,感谢您的帮助。

WebProxy myproxy = new WebProxy("IP Address", Port);
UdpClient client = new UdpClient();
string ipaddr = IPText.Text;
try
{
    client.Connect(ipaddr, 80);
    byte[] sendBytes = Encoding.ASCII.GetBytes(DataText.Text);
    client.Send(sendBytes, sendBytes.Length);
    client.AllowNatTraversal(true);
    client.DontFragment = true;
}

0 个答案:

没有答案
相关问题