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()
?
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.