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

前端 未结 1 1167
野的像风
野的像风 2020-12-06 08:51

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

So I opened up a socket on my machin. there are no nats between pe and proxy server. I connected to proxy server. Ho

相关标签:
1条回答
  • 2020-12-06 09:28

    You cannot open a socket 'thru' something, only 'to' something. With proxy server (I assume you're talking about HTTP proxy that supports 'CONNECT' command) it's the same: first open a connection to it, then use its protocol to make proxy forward your connection where you want to using 'CONNECT' command.

    So you need to do the following steps:

    1. Connect to proxy.
    2. Issue CONNECT Host:Port HTTP/1.1<CR><LF>
    3. Issue <CR><LF>
    4. Wait for a line of response. If it contains HTTP/1.X 200, the connection is successful.
    5. Read further lines of response until you receive an empty line.
    6. Now, you are connected to the outside world through a proxy. Do any data exchange you want.
    0 讨论(0)
提交回复
热议问题