[英]What does wildcard address in InetSocketAddress mean?
In the docs for the constructor InetSocketAddress(int port)
it says: 在构造函数InetSocketAddress(int port)
的文档中,它说:
Creates a socket address where the IP address is the wildcard address and the port number a specified value. 创建一个套接字地址,其中IP地址是通配符地址,端口号是指定值。
What does a wildcard address do and what does it means when used in socket.bind()
? 通配符地址做什么以及在socket.bind()
使用它意味着什么?
From the docs: The wildcard is a special local IP address. 从文档:通配符是一个特殊的本地IP地址。 It usually means "any" and can only be used for bind operations. 它通常表示“任何”,只能用于绑定操作。
The value of this IP address is 0.0.0.0. 该IP地址的值为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. 如果您有两个网络适配器,一个IP地址为1.1.1.1,另一个IP地址为2.2.2.2,那么您可以创建一个侦听套接字并将其绑定到1.1.1.1,以便套接字不会绑定到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. 您还可以创建一个侦听套接字并将其绑定到2.2.2.2,以便它不会绑定到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. 另一个特殊值是127.0.0.1,这意味着只有同一台计算机上的客户端才能连接到您的服务器。
A wildcard mask is a mask of bits that indicates which parts of an IP address can assume any value. 通配符掩码是位掩码,指示IP地址的哪些部分可以采用任何值。 In the Cisco IOS, they are used in several places, for example: 在Cisco IOS中,它们用于多个地方,例如:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.