但程序结果是出现这样的异常:
java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
at java.net.ServerSocket.bind(ServerSocket.java:319)
at java.net.ServerSocket.<init>(ServerSocket.java:185)
at java.net.ServerSocket.<init>(ServerSocket.java:97)
at com.itheima.TcpService.run(TcpService.java:18)
at java.lang.Thread.run(Thread.java:619)
Exception in thread "Thread-0" java.lang.NullPointerException
at com.itheima.TcpService.run(TcpService.java:40)
at java.lang.Thread.run(Thread.java:619)
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at java.net.Socket.<init>(Socket.java:366)
at java.net.Socket.<init>(Socket.java:180)
at com.itheima.TcpClient.run(TcpClient.java:15)
at java.lang.Thread.run(Thread.java:619)
java.lang.NullPointerException
at com.itheima.TcpClient.run(TcpClient.java:40)
at java.lang.Thread.run(Thread.java:619)
这个异常怎么解决?????????????????