C# TcpClient.Connect via a proxy

后端 未结 2 1559
无人共我
无人共我 2020-12-29 14:29

I\'ve searched high and low trying to figure this out, but everything I\'ve seen so far, people are just telling me to use other methods.

With that out of the way,

2条回答
  •  囚心锁ツ
    2020-12-29 14:52

    I use starksoft-aspen. It's free and open-source.

    In the example below the TcpClient initialized within "CreateConnection()" method, but you can also initialize the client by yourself, as well as do it all async.

    using Starksoft.Aspen.Proxy;
    
        Socks5ProxyClient proxyClient = new Socks5ProxyClient(
            socks5Proxy.Host, socks5Proxy.Port, 
            socks5Proxy.Username, socks5Proxy.Password);
    
        TcpClient client = proxyClient.CreateConnection(destination.Host, 
            destination.Port);
        NetworkStream stream = client.GetStream();
    

提交回复
热议问题