简体   繁体   English

InetSocketAddress中的通配符地址是什么意思?

[英]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中,它们用于多个地方,例如:

  • To indicate the size of a network or subnet for some routing protocols, such as OSPF. 指示某些路由协议(例如OSPF)的网络或子网的大小。
  • To indicate what IP addresses should be permitted or denied in access control lists (ACLs). 指示访问控制列表(ACL)中应允许或拒绝的IP地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java InetSocketAddress 看起来像 .toString() 吗? - What does Java InetSocketAddress look like .toString()? 使用任何主机的 IP 地址构造 InetSocketAddress 的正确方法是什么? - What is the correct way to construct InetSocketAddress with any host an IP address? vm前缀在地址行中的含义是什么? - What does vm prefix mean in the address line? 当一个对象的jvm地址为0时,它是什么意思? - What does it mean when the jvm address of an object is 0? servlet 映射 url-pattern 上的双通配符 (*) 是什么意思? - What does the double wildcard (*) on a servlet mapping url-pattern mean? “从IP地址创建套接字地址”是什么意思? - What does “Creates a socket address from an IP address” mean? Java的类型参数通配符到底意味着什么? Foo和Foo之间真正的区别是什么? <?> ? - What does Java's type parameter wildcard really mean? What's the real difference between Foo and Foo<?>? WSDL中的SOAP地址上的JMS:这是什么意思? - JMS on SOAP address location in a WSDL: What does it mean? 什么是&#39;通配符地址&#39;在UDP广播的背景下? - What is the 'wildcard address' In the context of UDP Broadcasts? 在Java &lt;= 0中是什么意思?0:1; - what does mean in java <=0?0:1;
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM