You cannot open a socket โthroughโ something, only โsomethingโ. With a proxy server (I assume you are talking about an HTTP proxy that supports the CONNECT command), the same thing: first open a connection to it, then use its protocol to force the proxy to redirect your connection where you want to use the command "CONNECT".
So, you need to take the following steps:
- Connect to a proxy.
- Problem
CONNECT Host:Port HTTP/1.1<CR><LF> - Problem
<CR><LF> - Wait for an answer. If it contains
HTTP/1.X 200, the connection will succeed. - Read the rest of the response line until you get an empty line.
- Now you are connecting to the outside world through a proxy. Do whatever data exchange you want.
source
share