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 do and what does it means when used in socket.bind()
?
In a policy, you only have to specify the wildcard IP address rather than add each individual IP address. To configure wildcard IP addresses in an alias or policy, you specify wildcard values in one or more octets in the netmask. Netmask values can be any number from 0 to 255.
Wildcards are special characters that can stand in for unknown characters in a text value and are handy for locating multiple items with similar, but not identical data. Wildcards can also help with getting data based on a specified pattern match. For example, finding everyone named John on Park Street.
It's an intermediary step.. And From API: It can also be a pair (hostname + port number), in which case an attempt will be made to resolve the hostname. If resolution fails then the address is said to be unresolved but can still be used on some circumstances like connecting through a proxy.
A socket address is defined by the IP address of the socket and the port number allocated to the socket.
Creates a socket address where the IP address is the wildcard address and the port number a specified value. What does a wildcard address do 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 only be used for bind operations.
InetSocketAddress (int port) : Creates a socketaddress object with the specified port number and a wildcard IP address. A wildcard IP address has the value 0.0.0.0 and it binds your socket to all network cards.
The wildcard is a special local IP address. It usually means "any" and can only be used for bind operations. The value of this IP address is 0.0.0.0.
The objects of this class are immutable and can be used for binding, connecting purposes. 1. InetSocketAddress (InetAddress addr, int port) : This constructor is similar to the general structure of a socket address with the attributes for Inet address and port number.
From the docs: The wildcard is a special local IP address. It usually means "any" and can only be used for bind operations.
The value of this IP address is 0.0.0.0. If you have two network adapters, one with IP address 1.1.1.1 and one with IP address 2.2.2.2, then you can create a listening socket and bind it to 1.1.1.1 so that the socket will not bind to 2.2.2.2. You can also create a listening socket and bind it to 2.2.2.2, so that it will not bind to 1.1.1.1. If you do not care and want your socket to bind to all network cards, then you bind it to the wildcard address.
Another special value would be 127.0.0.1, meaning that only clients on the same computer could connect to your server.
A wildcard mask is a mask of bits that indicates which parts of an IP address can assume any value. In the Cisco IOS, they are used in several places, for example:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With