简体   繁体   English

如何连接和断开代理?

[英]How can I connect and disconnect from a proxy?

I purchased a premium proxy and they only sent me an IP (51.38.119.210) and a username and password.我购买了一个高级代理,他们只给我发了一个 IP (51.38.119.210) 和一个用户名和密码。 I need this proxy in a C# project.我在 C# 项目中需要这个代理。 I need a single-line method that connects me and a method that disconnect.我需要一种连接我的单线方法和一种断开连接的方法。

I googled everywhere and found these codes:我到处搜索并找到这些代码:

WebRequest request = WebRequest.Create("51.38.119.210");
WebProxy proxy = (WebProxy)WebProxy.GetDefaultProxy();

I have never actually gotten to use Proxies that much in practice, so my knowledge is mostly from Networking Theory.在实践中我从来没有真正使用过代理,所以我的知识主要来自网络理论。

But I guess it does something like NAT with PortForwarding: Requests reaching it on a Interface and Port Y, always get routed to Interface and Port X (of course the Interface but not the port could be the same).但我想它会做一些类似于带有端口转发的 NAT:在接口和端口 Y 上到达它的请求,总是被路由到接口和端口 X(当然接口但不是端口可能相同)。 So it is all about setting the Server up with the proper fowarding (or whatever it is called for proxy severs).因此,这一切都是关于使用正确的转发(或代理服务器调用的任何内容)设置服务器。 And then send to it's incomming Port.然后发送到它的传入端口。

Wich is unfortunately a mater of Network/Server Administration and not programming.不幸的是,Wich 是网络/服务器管理专业而不是编程专业。 This also sounds a lot like a homework assignment.这听起来也很像家庭作业。 For those we do not provide code, only directions.对于那些我们不提供代码,只提供方向的人。

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

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