我编写了一个实现基本 Web 服务器的 java 类。它从控制台获取端口号。这段代码非常基本,它返回客户端发送的内容。代码如下:
package p106;
import java.io.*;
import java.net.*;
public class HttpMirror {
public static void main(String[] args) {
try
{
int port = Integer.parseInt(args[0]);
ServerSocket ss = new ServerSocket(port);
for(;;)
{
Socket client = ss.accept();
BufferedReader in = new BufferedReader( new InputStreamReader(client.getInputStream()));
PrintWriter out = new PrintWriter(client.getOutputStream());
out.print("HTTP/1.0 200 en");
out.print("Content-Type text/plain");
String line;
while( (line = in.readLine()) != null)
{
if(line.length() == 0)
break;
out.print(line );
}
out.close();
in.close();
client.close();
} // Tekrar döngüye gir ve bir sonraki bağlantıyı bekle.
}catch(Exception e)
{
System.err.println(e);
}
}
}
我运行这段代码,我必须在浏览器的地址栏中写些什么?提前致谢。