我正在使用 Mac 并尝试在本地计算机上运行服务器。这是代码
//1. creating a server socket
providerSocket = new ServerSocket(0, 10);
//2. Wait for connection
System.out.println("Waiting for connection");
try{
connection = providerSocket.accept();
}
catch (IOException ex){
System.err.println(ex);
}
System.out.println("Connection received from " + connection.getInetAddress().getHostName());
我看到打印“等待连接”但没有打印“从...收到连接”我看到代码仍在运行,这意味着接受()被阻止?我怎样才能解决这个问题 ?