forked from KNEMC/KLALB
KLALB完全大重写,代码规范了,可以当作网络库使用
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package org.kne.cloud.network.klalb;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.*;
|
||||
|
||||
import org.kne.cloud.network.mport.SocketBridge;
|
||||
import org.kne.cloud.network.mport.TCPListener;
|
||||
|
||||
public class KLALBTest2 {
|
||||
public static void main(String[] args) throws IOException, InterruptedException {
|
||||
ServerSocket ssk=new ServerSocket(8899);
|
||||
KLALBRemoteSocket s1=new KLALBRemoteSocket(ssk.accept());
|
||||
KLALBRemoteSocket s2=new KLALBRemoteSocket(ssk.accept());
|
||||
KLALBRemoteSocket s3=new KLALBRemoteSocket(ssk.accept());
|
||||
KLALBController cont=new KLALBController((Inet6Address) Inet6Address.getByName("::9"));
|
||||
cont.addRemoteSocket(s1);
|
||||
cont.addRemoteSocket(s2);
|
||||
cont.addRemoteSocket(s3);
|
||||
KLALBVirtualServerSocket ksr=new KLALBVirtualServerSocket(cont);
|
||||
TCPListener tl=new TCPListener(90);
|
||||
tl.setServerSocketFactory(new KLALBVirtualServerSocketFactory(cont));
|
||||
tl.setCon((x)->{
|
||||
try {
|
||||
new SocketBridge(x, new Socket("127.0.0.1",5212)).run();
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
tl.open();
|
||||
|
||||
Thread.sleep(20000);
|
||||
s3.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user