How to open a socket through a proxy server in .Net C #?

How to open a socket through a proxy server in .Net C #?

So, I opened the socket on my machine. there are no transitions between pe and the proxy server. I connected to the proxy server. How now to make requests from the global world of IP, which know that the proxy server address should be redirected or transmitted by the proxy server for me?

Any blog articles on blogs? Please, help

+3
source share
1 answer

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.
+6
source

Source: https://habr.com/ru/post/1751965/


All Articles