我有一个连接到代理的套接字,然后连接到我指定的远程服务器。但是我想要从代理到删除服务器的多个连接。所以我想为同一个代理创建 4 个套接字,并从 4 个套接字连接到远程服务器。
当我这样做时它不起作用,它只连接到代理一次。
这是伪代码:
static Socket[] liveCon = new Socket[300];
// This is the class that assigns a proxy and connects
// it is a temporary thread that connects and ends.
sockClass sockets = new sockClass;
class main {
for (int i = 0; i < livecon.length; i++) {
sockets[i].start(); // Thread ends after it is connected
}
}
class sockClass{
main.liveCon[index] = new Socket(proxy);
main.liveCon[index].connect(ep);
main.liveCon[index].setPerformancePreferences(1, 2, 0);
if (main.liveCon[index].isConnected() == true) {
myOutput = new PrintStream(main.liveCon[index].getOutputStream());
main.liveCon[index].setKeepAlive(true);
}
}