Files
KLALB/src/org/kne/cloud/network/klalb/KLALBTest2.java
T

37 lines
1.2 KiB
Java

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();
}
}