简体   繁体   English

如何在.Net C#中打开socket代理服务器?

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

How to open socket thru proxy server in .Net C#? 如何在.Net C#中打开socket代理服务器?

So I opened up a socket on my machin. 所以我在我的机器上打开了一个插座。 there are no nats between pe and proxy server. pe和代理服务器之间没有nat。 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? 现在如何从全球IP世界发出请求,知道代理服务器地址被代理服务器重定向或转移给我?

Any libs blog articles? 任何libs博客文章? Please help 请帮忙

You cannot open a socket 'thru' something, only 'to' something. 你无法打开套接字'thru',只能'to'某事。 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. 使用代理服务器(我假设您正在讨论支持'CONNECT'命令的HTTP代理)它是相同的:首先打开与它的连接,然后使用其协议使代理转发您想要使用'CONNECT'命令的连接。

So you need to do the following steps: 因此,您需要执行以下步骤:

  1. Connect to proxy. 连接到代理。
  2. Issue CONNECT Host:Port HTTP/1.1<CR><LF> 问题CONNECT Host:Port HTTP/1.1<CR><LF>
  3. Issue <CR><LF> 问题<CR><LF>
  4. Wait for a line of response. 等待回应。 If it contains HTTP/1.X 200 , the connection is successful. 如果它包含HTTP/1.X 200 ,则连接成功。
  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. 做你想要的任何数据交换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM