ServerSocket serverSocket = null;
int port = 8888;
try
{
serverSocket = new ServerSocket(port, 1, InetAddress.getByName("127.0.0.1"));
} catch (IOException e)
{
e.printStackTrace();
System.exit(1);
}
while (!shutdown)
{
Socket socket = null;
InputStream input = null;
OutputStream output = null;
try
{
/**
* 循环到此停止,在端口8888接收到一个HTTP请求才会继续
*/
socket = serverSocket.accept();
input = socket.getInputStream();
output = socket.getOutputStream();
} catch (Exception e)
{
e.printStackTrace();
continue;
}
}