testserver.java
来自「这是linux下ssl vpn的实现程序」· Java 代码 · 共 85 行
JAVA
85 行
/*
* Created on 08-May-2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import java.io.*;
import java.net.*;
import com.maverick.multiplex.MultiplexedConnection;
import com.maverick.multiplex.ChannelFactory;
import com.maverick.multiplex.Channel;
import com.maverick.multiplex.SocketChannel;
/**
* @author lee
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class TestServer implements Runnable {
MultiplexedConnection c;
public TestServer() {
Thread t1 = new Thread(this);
t1.start();
try {
ServerSocket server = new ServerSocket();
server.bind(new InetSocketAddress("0.0.0.0", 10000), 50);
Socket socket;
while ((socket = server.accept()) != null) {
c = new MultiplexedConnection(100,
100,
10000,
socket.getInputStream(),
socket.getOutputStream(),
new SocketChannelFactory());
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) {
TestServer t = new TestServer();
}
class SocketChannelFactory implements ChannelFactory {
public Channel createChannel(String type) {
return new SocketChannel();
}
}
public void run() {
try {
ServerSocket server = new ServerSocket();
server.bind(new InetSocketAddress("127.0.0.1", 8080), 50);
Socket socket;
while ((socket = server.accept()) != null) {
c.openChannel(new SocketChannel(socket, "3sp.com", 80));
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?