稳定性升级

This commit is contained in:
Administrator
2023-07-26 21:30:00 +08:00
parent 585b7c5fe6
commit 722ab9710f
30 changed files with 720 additions and 158 deletions
@@ -0,0 +1,32 @@
package org.kne.cloud.network.nathole;
import java.io.IOException;
import java.net.BindException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketOption;
import java.net.SocketOptions;
import java.nio.channels.SocketChannel;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class NatholeTestC {
public static ExecutorService exc=Executors.newCachedThreadPool();
public static void main(String[] args) throws IOException {
for (int i1 = 1024; i1 < 65536; i1++) {
int i2=i1;
exc.execute(()->{
try {
Socket s=new Socket();
System.out.println(i2);
s.bind(new InetSocketAddress("0.0.0.0", i2));
s.connect(new InetSocketAddress("10.235.16.1", 10400), 100);
System.out.println("成功!");
System.exit(0);
} catch (IOException e) {
}
});
}
}
}
@@ -0,0 +1,36 @@
package org.kne.cloud.network.nathole;
import java.io.IOException;
import java.net.BindException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.channels.SocketChannel;
public class NatholeTestS {
public static void main(String[] args) throws IOException {
for (int i1 = 1024; i1 < 65536; i1++) {
try {
SocketChannel sc= SocketChannel.open();
sc.configureBlocking(false) ;
sc.bind(new InetSocketAddress("0.0.0.0", i1));
sc.connect(new InetSocketAddress("10.235.16.1",10300));
sc.close();
int i2=i1;
new Thread(()->{
try {
ServerSocket ssk=new ServerSocket(i2);
while(true) {
Socket s=ssk.accept();
System.out.println(s);
}
} catch (IOException e) {
e.printStackTrace();
}
} ).start();
System.out.println(i1);
}catch(BindException e) {
}
}
}
}