📄 multwebserver.java
字号:
/**
* This is a multthread web server responds for get mehtod
* return thml page or images like gif and jpeg.
* author:庾欢 张娟 张维
* date: 06.10.29
*/
import java.net.* ;
public final class MultWebServer
{
public static void main(String argv[]) throws Exception
{
//Set the port number.
//choose any port higher than 1024
int port = 6788;
//Establish the server socket that listens for incoming connection
ServerSocket listenSocket = new ServerSocket(port);
//Process HTTP service requests in an infinite loop.
while (true) {
// Listen for a TCP connection request.
Socket connectionSocket = listenSocket.accept();
//Construct an object to process the HTTP request message.
HttpRequest request = new HttpRequest(connectionSocket);
//Create a new thread to process the request.
Thread thread = new Thread(request);
// Start the thread.
thread.start();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -