⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 multwebserver.java

📁 多线程服务器功能: 从同一局域网的不同主机发起请求; 从同一机器的多个浏览器发起请求; 访问各种格式文件;
💻 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 + -