Hello,
Rebex components include ProxySocket
object in the Rebex.Networking.dll. ProxySocket is a client-side HTTP, Socks4 and Socks5 proxy object that is used by our client objects (e.g. POP3, IMAP SFTP, FTP, etc). It can be used stand-alone as well, and other protocols can be run over it.
Not knowing what protocol you are using (?) I wrote a sample code that can be used to connect to an HTTP server through a proxy to demonstrate its capabilities:
// create a proxy socket
Proxy proxy = new Proxy(ProxyType.Socks5, "proxy-example.org", 1080);
// specify other parameters if needed, e.g. username and password
proxy.UserName = "proxy-user";
proxy.Password = "proxy-password";
// create an instance of Rebex.Net.Proxysocket
ProxySocket proxySocket = new ProxySocket(proxy);
// connect to server through the proxy
proxySocket.Connect("http-server01", 80);
// send a request
byte[] request = Encoding.ASCII.GetBytes("GET / HTTP/1.1\r\nHost: server01\r\n\r\n");
proxySocket.Send(request);
// receive response (needs to be actually implemented)
byte[] response = new byte[4096];
proxySocket.Receive(response);
...
However, to actually make this usable, you would have to provide a client object that can use the ProxySocket object as its transport layer. But given that you already are using System.Net.Sockets.TcpClient, this must be obvious.
Let me know whether the ProxySocket class solves your needs. In fact, you can purchase is as part of any Rebex networking-capable component. (The cheapest one being Rebex Time).