Exceptions that may be thrown when a JAVA socket connects to a server

Source: Internet
Author: User

1, Unknownhostexception:host (non-IP) can not know, will report the exception, www.google.com.hk Although the ping does not make sense, but will not report the error, because he is a real domain name. He's going to report connectionexception.

2, connectexception: generally IP or host or domain name is through, but the port is not through, will report the error. In addition, if the domain name exists, but the network if the restrictions, will also report the wrong. If the server does a limit on the number of connections, it will be reported if the client has too many simultaneous connections.

The configuration of the number of server connections is as follows: public serversocket (int port, int backlog, inetaddress bindaddr). The backlog is the maximum number of simultaneous connections the client has to limit parameters.

3. Sockettimeoutexception: This exception was introduced in my blog (the use of JAVA socket-free constructor method).

4, Bindexception: In general, the port is occupied, when the port is used again, the error will be reported.

Exceptions that may be thrown when a JAVA socket connects to a server

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.