首页 > 编程语言 > 详细

Exception in thread "main" java.net.ConnectException: Connection refused: connect

时间:2020-07-27 13:14:48      阅读:87      评论:0      收藏:0      [点我收藏+]

 

客户端连接异常:

Exception in thread "main" java.net.ConnectException: Connection refused: connect
    at sun.nio.ch.Net.connect0(Native Method)
    at sun.nio.ch.Net.connect(Net.java:454)
    at sun.nio.ch.Net.connect(Net.java:446)
    at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:648)
    at homework.test5.client.main(client.java:16)

原因:

1、server服务器未开启,客户端与服务器的设置端口不一致;

2、也可能是server运行后,ServerSocker.close()、ServerSocketChannel.close()、synchronousServerSocketChannel.close()。所以服务器在客户端连接之前不能关闭,或者就不关闭服务器。

Exception in thread "main" java.net.ConnectException: Connection refused: connect

原文:https://www.cnblogs.com/chenfx/p/13384667.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!