好的,所以我对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)
答案 0 :(得分:2)
让你的代码 - 必须改变主机的IP,但否则一切都好。因此,可以确认这是一个IP /防火墙问题。仔细检查您的IP地址的ipconfig / ifconfig。对不起,但还不能对问题发表评论:(