14
java.net.ConnectException:连接被拒绝
我正在尝试实现TCP连接,从服务器端一切正常,但是当我运行客户端程序(从客户端计算机)时,出现以下错误: java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432) at java.net.Socket.connect(Socket.java:529) at java.net.Socket.connect(Socket.java:478) at java.net.Socket.<init>(Socket.java:375) at java.net.Socket.<init>(Socket.java:189) at TCPClient.main(TCPClient.java:13) 我尝试更改套接字号以防万一,但无济于事,有谁知道导致此错误的原因和解决方法。 服务器代码: //TCPServer.java import java.io.*; import java.net.*; class TCPServer { public static void main(String argv[]) throws Exception { String fromclient; String toclient; ServerSocket Server = …
185
java
networking
tcp