<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # QHostAddress Class Reference ## [[QtNetwork](index.htm) module] 該QHostAddress類提供一個IP地址。[More...](#details) ### Types * `enum SpecialAddress { Null, Broadcast, LocalHost, LocalHostIPv6, AnyIPv6, Any }` ### Methods * `__init__ (self)` * `__init__ (self, SpecialAddress?address)` * `__init__ (self, int?ip4Addr)` * `__init__ (self, QString?address)` * `__init__ (self, 16-tuple-of-int?ip6Addr)` * `__init__ (self, QHostAddress?copy)` * `clear (self)` * `bool isInSubnet (self, QHostAddress?subnet, int?netmask)` * `bool isInSubnet (self, tuple-of-QHostAddress-int?subnet)` * `bool isNull (self)` * `QAbstractSocket.NetworkLayerProtocol protocol (self)` * `QString scopeId (self)` * `setAddress (self, int?ip4Addr)` * `bool setAddress (self, QString?address)` * `setAddress (self, 16-tuple-of-int?ip6Addr)` * `setScopeId (self, QString?id)` * `int toIPv4Address (self)` * `16-tuple-of-int toIPv6Address (self)` * `QString toString (self)` ### Static Methods * `tuple-of-QHostAddress-int parseSubnet (QString?subnet)` ### Special Methods * `bool __eq__ (self, QHostAddress?address)` * `bool __eq__ (self, SpecialAddress?address)` * `int __hash__ (self)` * `bool __ne__ (self, QHostAddress?address)` * `bool __ne__ (self, SpecialAddress?address)` * * * ## Detailed Description 該QHostAddress類提供一個IP地址。 此類包含IPv4或IPv6地址在一個平臺和協議無關的方式。 QHostAddress通常與所使用的[QTcpSocket](qtcpsocket.html),[QTcpServer](qtcpserver.html)和[QUdpSocket](qudpsocket.html)連接到主機或設立一個服務器。 主機地址設置與[setAddress](qhostaddress.html#setAddress)() ,并檢索與[toIPv4Address](qhostaddress.html#toIPv4Address)( )[toIPv6Address](qhostaddress.html#toIPv6Address)() ,或[toString](qhostaddress.html#toString)( ) 。您可以檢查與類型[protocol](qhostaddress.html#protocol)( ) 。 **Note:**請注意, QHostAddress沒有做DNS查找。[QHostInfo](qhostinfo.html)是需要這一點。 該類還支持常見的預定義的地址:[Null](qhostaddress.html#SpecialAddress-enum),[LocalHost](qhostaddress.html#SpecialAddress-enum),[LocalHostIPv6](qhostaddress.html#SpecialAddress-enum),[Broadcast](qhostaddress.html#SpecialAddress-enum)和[Any](qhostaddress.html#SpecialAddress-enum)。 * * * ## Type Documentation ``` QHostAddress.SpecialAddress ``` | Constant | Value | Description | | --- | --- | --- | | `QHostAddress.Null` | `0` | 空地址的對象。相當于[QHostAddress](qhostaddress.html#QHostAddress)( ) 。 | | `QHostAddress.LocalHost` | `2` | 在本地主機的IPv4地址。相當于[QHostAddress](qhostaddress.html)( “127.0.0.1” ) 。 | | `QHostAddress.LocalHostIPv6` | `3` | IPv6的本地主機地址。相當于[QHostAddress](qhostaddress.html)( “.1” ) 。 | | `QHostAddress.Broadcast` | `1` | IPv4的廣播地址。相當于[QHostAddress](qhostaddress.html)( “255.255.255.255” ) 。 | | `QHostAddress.Any` | `4` | IPv4的任何地址。相當于[QHostAddress](qhostaddress.html)( “0.0.0.0” ) 。 | | `QHostAddress.AnyIPv6` | `5` | IPv6的任何地址。相當于[QHostAddress](qhostaddress.html)( “[.](index.html)“ ) 。 | * * * ## Method Documentation ``` QHostAddress.__init__ (self) ``` 構造一個主機地址對象的IP地址為0.0.0.0 。 **See also** [clear](qhostaddress.html#clear)( ) 。 ``` QHostAddress.__init__ (self, SpecialAddress?address) ``` 構造一個主機地址對象的IPv4地址_ip4Addr_。 ``` QHostAddress.__init__ (self, int?ip4Addr) ``` 構造一個主機地址對象的IPv6地址_ip6Addr_。 _ip6Addr_必須是網絡字節順序(大端)一個16字節的數組。 ``` QHostAddress.__init__ (self, QString?address) ``` 構造一個主機地址對象的IPv6地址_ip6Addr_。 ``` QHostAddress.__init__ (self, 16-tuple-of-int?ip6Addr) ``` 構造使用由天然結構中指定的地址的IPv4或IPv6地址_sockaddr_。 **See also** [setAddress](qhostaddress.html#setAddress)( ) 。 ``` QHostAddress.__init__ (self, QHostAddress?copy) ``` 構建了基于字符串的IPv4或IPv6地址_address_(例如, “127.0.0.1” ) 。 **See also** [setAddress](qhostaddress.html#setAddress)( ) 。 ``` QHostAddress.clear (self) ``` 設置主機地址為0.0.0.0 。 ``` bool QHostAddress.isInSubnet (self, QHostAddress?subnet, int?netmask) ``` 返回True如果這個IP是由網絡前綴描述的子網_subnet_和網絡掩碼_netmask_。 一個IP被認為是屬于一個子網,如果它包含的最低和該子網中的最高地址。在IP版本4的情況下,最低的地址是網絡地址,而最高地址是廣播地址。 該_subnet_參數并不一定是實際的網絡地址(子網中的最低地址) 。它可以是屬于該子網的任何有效的IP地址。特別是,如果它等于通過這個對象持有的IP地址,這個函數將始終返回True (所提供的網絡掩碼是一個有效的值) 。 此功能被引入Qt的4.5 。 **See also** [parseSubnet](qhostaddress.html#parseSubnet)( ) 。 ``` bool QHostAddress.isInSubnet (self, tuple-of-QHostAddress-int?subnet) ``` 這是一個重載函數。 返回True如果這個IP是由描述的子網_subnet_。該[QHostAddress](qhostaddress.html)成員_subnet_包含網絡前綴和整數(二)成員包含子網掩碼(前綴長度) 。 此功能被引入Qt的4.5 。 ``` bool QHostAddress.isNull (self) ``` 返回True如果主機地址為空( INADDR_ANY或IN6ADDR_ANY ) 。默認的構造函數創建一個空的地址,該地址是無效的任何主機或接口。 ``` tuple-of-QHostAddress-int QHostAddress.parseSubnet (QString?subnet) ``` 解析包含在IP和子網信息_subnet_并返回網絡前綴的網絡前綴長度。 IP地址和網絡掩碼必須以斜杠( / )分隔。 此功能支持形式參數: * 123.123.123.123/n where n is any value between 0 and 32 * 123.123.123.123/255.255.255.255 * &lt;ipv6-address&gt;/n where n is any value between 0 and 128 對于IP版本4 ,這個函數接受以及缺少結尾的部分(即,小于4個字節,如“ 192.168.1 ” ),其次或不點。如果子網掩碼也在這種情況下丟失,它被設置為實際傳遞的字節數(在上面的例子中,這將是24 ,為3個八比特組) 。 此功能被引入Qt的4.5 。 **See also** [isInSubnet](qhostaddress.html#isInSubnet)( ) 。 ``` QAbstractSocket.NetworkLayerProtocol QHostAddress.protocol (self) ``` [ 返回主機地址中的網絡層協議。 ``` QString QHostAddress.scopeId (self) ``` ](qabstractsocket.html#NetworkLayerProtocol-enum) [返回一個IPv6地址的范圍ID 。對于IPv4地址,或者地址不包含范圍ID ,一個空](qabstractsocket.html#NetworkLayerProtocol-enum)[QString](qstring.html)返回。 IPv6的范圍ID指定的范圍_reachability_對于非全局IPv6地址,限制在其中的地址可使用的區域。所有的IPv6地址與這樣的可達范圍有關。范圍ID被用來消除那些不能保證是全局唯一的地址。 的IPv6指定了以下四個層次的可達性: * Node-local: Addresses that are only used for communicating with services on the same interface (e.g., the loopback interface ".1"). * Link-local: Addresses that are local to the network interface (_link_). There is always one link-local address for each IPv6 interface on your host. Link-local addresses ("fe80...") are generated from the MAC address of the local network adaptor, and are not guaranteed to be unique. * Site-local: Addresses that are local to the site / private network (e.g., the company intranet). Site-local addresses ("fec0...") are usually distributed by the site router, and are not guaranteed to be unique outside of the local site. * Global: For globally routable addresses, such as public servers on the Internet. 當使用鏈路本地和站點本地地址的IPv6連接,則必須指定范圍ID 。一個鏈路本地地址的范圍ID通常是相同的接口名稱(例如,“ eth0的” , “ EN1 ” )或數字(例如, “ 1 ” , “2” ) 。 這個函數是Qt 4.1中引入。 **See also** [setScopeId](qhostaddress.html#setScopeId)( ) 。 ``` QHostAddress.setAddress (self, int?ip4Addr) ``` 通過設置指定的IPv4地址_ip4Addr_。 ``` bool QHostAddress.setAddress (self, QString?address) ``` 這是一個重載函數。 通過設置指定的IPv6地址_ip6Addr_。 _ip6Addr_必須是網絡字節順序(高位字節在前) 16字節的數組。 ``` QHostAddress.setAddress (self, 16-tuple-of-int?ip6Addr) ``` 這是一個重載函數。 通過設置指定的IPv6地址_ip6Addr_。 ``` QHostAddress.setScopeId (self, QString?id) ``` 設置地址的IPv6范圍ID來_id_。如果地址協議是不支持IPv6 ,這個函數不執行任何操作。 這個函數是Qt 4.1中引入。 **See also** [scopeId](qhostaddress.html#scopeId)( ) 。 ``` int QHostAddress.toIPv4Address (self) ``` 返回的IPv4地址為一個數字。 例如,如果地址是127.0.0.1 ,則返回值是2130706433 (即0x7f000001 ) 。 此值才有效,如果該協議( )是[IPv4Protocol](qabstractsocket.html#NetworkLayerProtocol-enum)。 **See also** [toString](qhostaddress.html#toString)( ) 。 ``` 16-tuple-of-int QHostAddress.toIPv6Address (self) ``` 返回IPv6地址作為Q_IPV6ADDR結構。該結構由16位無符號的字符。 ``` Q_IPV6ADDR addr = hostAddr.toIPv6Address(); // addr contains 16 unsigned characters for (int i = 0; i < 16; ++i) { // process addr[i] } ``` 此值才有效,如果[protocol](qhostaddress.html#protocol)()是[IPv6Protocol](qabstractsocket.html#NetworkLayerProtocol-enum)。 **See also** [toString](qhostaddress.html#toString)( ) 。 ``` QString QHostAddress.toString (self) ``` 返回該地址為一個字符串。 例如,如果該地址是IPv4地址127.0.0.1 ,則返回的字符串為“ 127.0.0.1” 。對于IPv6的字符串格式將遵循RFC5952建議。 **See also** [toIPv4Address](qhostaddress.html#toIPv4Address)( ) 。 ``` bool QHostAddress.__eq__ (self, QHostAddress?address) ``` ``` bool QHostAddress.__eq__ (self, SpecialAddress?address) ``` ``` int QHostAddress.__hash__ (self) ``` ``` bool QHostAddress.__ne__ (self, QHostAddress?address) ``` ``` bool QHostAddress.__ne__ (self, SpecialAddress?address) ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看