阅读以下说明、Java源程序和运行测试部分,将应填入(n)处的解答写在对应栏中。
1. HTTP 协议
HTTP请 求消息示例
GET/index, htmIHTTP/1.1
Accept: image/gif, image/jpeg, */*
Accept-Language: zh-ch
Accept-encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE6.0; Windows NT5.1)
Host: IocaIhost: 8080
Connection: Keep-Alive
HTTP/1.1 200 OK
Servert: Microsoft-IIS/4.0
Date: Mon, 3 Jan 1998 13:13:33 GMT
Content-Type: text/html
Last-Modified: Mon, 11 Jan 1998 13:23:42 GMT
Contelit-Length: 112
# < html >
…
2.相关类及主要成员函数
ServerSocket类:
服务器端套接字,它监听固定端口,以接收来自客户端的连接请求,一旦建立连接就返回一个Socket类型的对象。类中的主要成员函数见表1。
.jpg)
基于连接的套接字。类中的主要成员函数见表2。
【正确答案】正确答案:(1)ServerSocket(PORT)或ServerSocket(PORT,1,InetAddress.getByName (“127.0.0.1”)) (2)serverSocket. accept( ) (3)8etlnputStream( ) (4)getOutputStream( ) (5)Response(output( ) (6)sendStaticResource( ) (7)socket. close( ) (8)printStackTrace( ) (9)hnp://localhost:8080/index.html或http://127.0.0.1:8080/ index.html. (10)http://localhost:8080/shutdown或http://127.0.0.1: 8080/Shutdo
【答案解析】