ConnectException:连接被拒绝
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.javaimport java.io.*;import java.net.*;class TCPServer { public static void main(String argv[]) throws Exception { String fromclient; String toclient; ServerSocket Server = new ServerSocket(5000); System.out.println("TCPServer Waiting for client on port 5000"); while (true) { Socket connected = Server.accept(); System.out.println(" THE CLIENT" + " " + connected.getInetAddress() + ":" + connected.getPort() + " IS CONNECTED "); BufferedReader inFromUser = new BufferedReader( new InputStreamReader(System.in)); BufferedReader inFromClient = new BufferedReader( new InputStreamReader(connected.getInputStream())); PrintWriter outToClient = new PrintWriter( connected.getOutputStream(), true); while (true) {
阿晨1998
HUH函数
相关分类