1

好的,所以我对 Java 套接字完全陌生,我真的不知道这个问题,我的好朋友告诉我在这里发布。

客户: http: //www.pastie.org/4163360

服务器: http: //www.pastie.org/4163364

运行客户端时收到的错误:

Exception in thread "main" java.net.ConnectException: Connection timed out: 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 talk.Client.main(Client.java:36)
4

1 回答 1

2

运行您的代码 - 必须更改主机的 IP,否则一切正常。因此,可以确认这是一个 IP/防火墙问题。仔细检查您的 ipconfig / ifconfig 以获取您的 IP 地址。对不起,但还不能对问题发表评论:(

于 2012-06-28T02:28:16.287 回答