"Turn" java.net.SocketException

Source: Internet
Author: User

The 1th exception is java.net.BindException:Address already in Use:jvm_bind. This exception occurs when the server side operates on a new ServerSocket (port is an integer value of 0,65536). The exception is due to the fact that a port is already being started and is listening. At this point, with the Netstat–an command, you can see a port with a listending status. Just find an unoccupied port to solve this problem.

The 2nd exception is Java.net.ConnectException:Connection Refused:connect. This exception occurs when the client makes a new Socket (IP, Port) operation because the exception occurs because either the machine with the IP address cannot be found (that is, the current machine does not exist to the specified IP route), or the IP exists, but the specified port is not found for listening. This problem occurs, first check the client's IP and port is wrong, if it is correct to ping the server from the client to see if it can ping, if you can ping (the service server to ping off the need for another method), the server-side listening to the specified port program is started, This will certainly solve the problem.

The 3rd exception is the Java.net.SocketException:Socket is closed, which can occur on both the client and the server. The reason for the exception is that you have actively closed the connection (called the Close method of the socket) and read and write the network connection.

The 4th exception is java.net.SocketException: (Connection reset or connect reset by Peer:socket write error). This exception can occur on both the client and the server side, causing the exception to be two, the first of which is if the socket on one end is turned off (or closed by an unexpected exit), the other end still sends the data, and the first packet that is sent throws the exception (Connect reset by Peer). The other is one end exiting, but the connection is not closed when exiting, and the other end throws the exception if the data is read from the connection (Connection reset). The simple thing is that the read and write operations are caused by the disconnection of the connection.

The 5th exception is the Java.net.SocketException:Broken pipe. This exception can occur on both the client and the server. In the first case of the 4th exception (that is, after you throw socketexcepton:connect reset by Peer:socket write error), the exception is thrown if you continue to write the data. The solution to the first two exceptions is to first ensure that all network connections are closed before the program exits, followed by detection of the other's closed connection operation, and that the other person closes the connection after closing the connection.

"Turn" java.net.SocketException

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.