Java.net. socketexception: Connection Reset

Source: Internet
Author: User
Tags connection reset

The first exception is java.net. bindexception: address already in use: jvm_bind. This exception occurs when the server performs the new serversocket (port) (port is an integer value of) operation. The cause of the exception is that the same port has been started and listened. Run the netstat-An command to view the port in the listending status. You only need to find an unused port to solve this problem.

The first exception is java.net. connectexception: Connection refused: connect. This exception occurs when the client performs the new socket (IP, Port) operation, the cause of this exception is that the machine with the IP address cannot be found (that is, the current machine does not exist to the specified IP address route), or the IP address exists, but the specified port cannot be found for listening. In this case, first check whether the client's IP address and port are written incorrectly. If yes, ping the server from the client to check whether the server can be pinged, if the Ping is successful (the server can disable the ping operation, you need another method). Check whether the program on the specified port of the server listener is started. This will definitely solve this problem.

The first exception is java.net. socketexception: socket is closed, which can occur on both the client and server. The exception occurs when you close the connection (call the socket close method) and perform read/write operations on the network connection.

The first exception is java.net. socketexception: (Connection Reset or connect reset by peer: Socket write error ). This exception may occur on both the client and server. There are two reasons for this exception, the first one is that if the socket at one end is closed (or the socket is closed actively or caused by abnormal exit), the other end still sends data, the first packet sent causes this exception (connect reset by peer ). The other end exits, but does not close the connection when exiting. If the other end reads data from the connection, this exception (Connection Reset) is thrown ). In short, it is caused by read and write operations after the connection is disconnected.

The first exception is java.net. socketexception: broken pipe. This exception may occur on both the client and server. In the first case of 4th exceptions (that is, after throwing socketaskton: connect reset by peer: Socket write error), if you continue writing data, this exception is thrown. The solution to the first two exceptions is to first ensure that all network connections are closed before the program exits, and secondly, to detect the closing operation of the other party and disable the connection after the other party closes the connection.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.