What does wildcard address in inetsocketaddress mean?

Source: Internet
Author: User

In the docs for the constructor InetSocketAddress(int port) it says:

Creates a socket address where the IP address is the wildcard address and the port number a specified value.

What does a wildcard address does and what does it means when used in socket.bind() ?

From the docs:the wildcard is a special local IP address. It usually means "any" and can is only being used for bind operations.

The value of this IP address is 0.0.0.0. If you have both network adapters, one with the IP address 1.1.1.1 and one with the IP address 2.2.2.2, then you can create a Liste Ning socket and bind it to 1.1.1.1 so the socket would not bind to 2.2.2.2. You can also create a listening socket and bind it to 2.2.2.2, so it would not bind to 1.1.1.1. If you don't care and want your sockets to bind to all network cards, then you bind it to the wildcard address.

Another special value would be 127.0.0.1, meaning this only clients on the same computer could connect to your server.

What does wildcard address in inetsocketaddress mean?

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.