问题描述
我一直想使用ServerSocket
在回送设备上创建服务器。
ServerSocket server = new ServerSocket(PORT,InetAddress.getByName(null));
到达服务器的主机以ip6-localhost/::1
的形式提供,但会导致错误:ERR_INVALID_HTTP_RESPONSE
关于如何使用127.0.0.1
访问本地服务器的任何指针?
解决方法
this question中的某些答案和评论解决了此问题。即-传入localhost
或127.0.0.1
ServerSocket server = new ServerSocket(9090,InetAddress.getByName("localhost"))