Socket exception
Client exception
java.net.ConnectException: Connection refused: connect.
This exception occurs when the client performs new Socket(ip, port) operation. The reason for this exception is that either the machine with the IP address cannot be found (that is, from the current machine does not exist to the specified IP route), or the IP exists, but the specified port cannot be found for listening. If this problem occurs, first check whether the client's ip and port are written incorrectly. If it is correct, ping the server from the client to see if it can be pinged. If it can be pinged (the service server ping is disabled, another method is required), then it depends on whether the program listening to the specified port on the server side is started.
java.net.SocketException: Socket is closed
The common reason is that after the connection is closed (the Socket's close method is called), the network connection is read and write.
java.net.SocketException: (Connection reset or Connect reset by peer:Socket write error)
The first is that if the Socket on one end is closed (or actively closed or closed due to an exception exit), the other end still sends data, and the first data packet sent raises the exception (Connect reset by peer). The other is that one end exits, but the connection is not closed when exiting, and the other end throws the Connection reset if data is being read from the connection. Simply put, it is caused by read and write operations after the connection is disconnected.
java.net.SocketException: Broken pipe.
After throwing SocketExcepton:Connect reset by peer:Socket write error, if you continue to write data, the exception will be thrown.
(Not measured yet)
java.net.BindException:Address already in use: JVM_Bind.
This exception occurs when the server side performs new ServerSocket(port) (port is an integer value of 0, 65536). The reason for the exception is that a port, the same as the port, has been started and listened for. At this time, use the netstat an command to see a port in the Listening state. You only need to find a port that is not occupied to solve this problem.
java.net.SocketException: Socket is closed
(Same as client)
java.net.SocketException: (Connection reset or Connect reset by peer:Socket write error)
(Same as client)
java.net.SocketException: Broken pipe.
Thank you for reading, I hope it can help you. Thank you for your support for this site!