在运行server2文件后,在浏览器中输入www.localhost:9998/后
浏览器得不到服务器所发送的字符串,服务器也没报错,请问一下是什么原因?
package socket;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class server2 {
public static void main(String[] args) throws Exception {
ServerSocket serverSocket = new ServerSocket(9998);
System.out.println("=====我的 web 服务在 9998 端口监听=====");
Socket socket = serverSocket.accept();
OutputStream outputStream = socket.getOutputStream();
outputStream.write("hello world 9998~".getBytes());
outputStream.close();
socket.close();
serverSocket.close();
}
}