问答详情
源自:3-3 编程实现基于 TCP 的 Socke t通信之客户端

服务器与客服端响应一次后失效

客服端运行不了

                    Socket socket=new Socket("localhost",8888);

java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at com.imoc.Client.main(Client.java:16)

提问者:Miaih 2017-09-06 02:29

个回答

  • 慕少7573967
    2017-09-27 14:03:35

    换个端口号

  • Miaih
    2017-09-06 12:05:33

    没有啊 就最后关闭资源关闭了socket

  • 梦里最相思
    2017-09-06 09:43:06

    多线程类里面,你是不是把socket关闭了