最初我在通配符地址 0.0.0.0 中占用了端口 80
现在我试图将此端口 80 绑定到一个可用的 ipaddress 中,比如 172.18.81.56
The following exception occurred
java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
但是从Windows服务(wrapper.exe)执行相同的代码时没有异常,服务器套接字创建成功,可能是什么问题......
here the piece of code
ServerSocket ss = null;
try
{
serverHost = "172.18.81.56";
InetAddress ina = InetAddress.getByName(serverHost);
ss = new ServerSocket(port, 10, ina);
ss.close();
}
catch(Exception e)
{
e.printStackTrace();
}