java.net.SocketException: Invalid argument: connect

后端 未结 8 2274
闹比i
闹比i 2020-12-01 18:47

My new laptop (Alienware m17x) throws a java.net.SocketException: Invalid argument: connect when I run the following basic code:

Server.java:



        
8条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 19:11

    Your machine seems to have an IPv6 configuration and is preferred by default in Java so try start your server and client with -Djava.net.preferIPv4Stack=true as JVM args:

      java -Djava.net.preferIPv4Stack=true Client.main
    

    Also make sure you didn't deny the application network access when Windows' Firewall asked you for permission. If you did, you can change the settings in the control panel.

提交回复
热议问题