📄 testserver.java
字号:
/*
* 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -