如何在 .Net C# 中通过代理服务器打开套接字?

如何在 .Net C# 中通过代理服务器打开套接字?

问题描述:

如何在 .Net C# 中通过代理服务器打开套接字?

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

所以我在我的机器上打开了一个插座.pe 和代理服务器之间没有 nats.我连接到代理服务器.现在如何使来自知道代理服务器地址的全球 IP 世界的请求被代理服务器重定向或传输给我?

So I opened up a socket on my machin. there are no nats between pe and proxy server. I connected to proxy server. How now to make Requests from global IP world that know that proxy server adrress be redirected or transfered by proxy server to me?

任何 libs 博客文章?请帮忙

Any libs blog articles? Please help

您不能打开套接字通过"某物,只能到"某物.使用代理服务器(我假设您在谈论支持CONNECT"命令的 HTTP 代理)是相同的:首先打开一个连接,然后使用它的协议使代理转发您想要使用CONNECT"命令的连接.

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. 连接到代理.
  2. 问题 CONNECT Host:Port HTTP/1.1
  3. 问题
  4. 等待一行响应.如果包含HTTP/1.X 200,则连接成功.
  5. 阅读更多的回复行,直到收到空行.
  6. 现在,您通过代理连接到外部世界.进行任何您想要的数据交换.