[英]Using FTP Proxy with apache commons-net
I want to set up an FTP connection using a proxy server with Apache's commons-net. 我想使用Apache的commons-net使用代理服务器建立FTP连接。
But looking at this Does FTPClient support FTP connections through an FTP proxy server? 但是看看这个FTPClient是否支持通过FTP代理服务器的FTP连接? has me worried. 让我担心
I have to meddle with the system properties and the Sun docs state that "If socksProxyHost is specified then all TCP sockets will use the SOCKS proxy server to establish a connection or accept one." 我必须干涉系统属性,Sun文档声明“如果指定了socksProxyHost ,那么所有TCP套接字都将使用SOCKS代理服务器建立连接或接受连接。”
WTH? WTH? All TCP sockets? 所有TCP套接字? What about my database connections? 我的数据库连接怎么样? Or other FTP connections i might want to open at the same time not using a proxy? 或者其他FTP连接我可能想要在不使用代理的情况下同时打开? Will they all be affected? 他们都会受到影响吗?
Is there some other way to do it that doesn't mess with the rest of my application? 有没有其他方法可以做到这一点不会弄乱我的应用程序的其余部分?
You have several ways of using proxies in Java, especially from version 1.5. 您有几种在Java中使用代理的方法,尤其是1.5版本。
java.net.Proxy
class (Java 1.5+) to set (or not) a Proxy
per Connection
使用java.net.Proxy
类(Java 1.5+)为每个Connection
设置(或不设置) Proxy
java.net.ProxySelector
(idem) which will determine a Proxy
for each Connection
according to your criteria 实现java.net.ProxySelector
(idem),它将根据您的条件为每个Connection
确定Proxy
See the detailled Sun technote on networking & proxies . 请参阅有关网络和代理的详细Sun技术说明 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.