Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.network
Class QHostAddress

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.network.QHostAddress

All Implemented Interfaces:
  QtJambiInterface, java.lang.Cloneable

    public class QHostAddress

extends QtJambiObject
implements java.lang.Cloneable

The QHostAddress class provides an IP address. This class holds an IPv4 or IPv6 address in a platform- and protocol-independent manner.

QHostAddress is normally used with the `QTcpSocket`, `QTcpServer`, and `QUdpSocket` to connect to a host or to set up a server.

A host address is set with `setAddress()`, checked for its type using isIPv4Address() or isIPv6Address(), and retrieved with `toIPv4Address()`, `toIPv6Address()`, or `toString()`.

The class also supports common predefined addresses: `Null` , `LocalHost` , `LocalHostIPv6` , `Broadcast` , and `Any` .

See also:
  `QTcpSocket`, `QTcpServer`, and `QUdpSocket`.

Nested Class Summary
`static class` | `QHostAddress.SpecialAddress`

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QHostAddress()` Constructs a host address object with the IP address 0.
`QHostAddress(int ip4Addr)` Constructs a host address object with the IPv4 address `ip4Addr`.
`QHostAddress(QHostAddress.SpecialAddress address)` Constructs a QHostAddress object for `address`.
`QHostAddress(QHostAddress copy)` Constructs a copy of the given `address`.
`QHostAddress(QIPv6Address ip6Addr)` Creates a QHostAddress from the specified `ip6Addr` address.
`QHostAddress(java.lang.String address)` Constructs an IPv4 or IPv6 address based on the string `address` (e.

Method Summary
`void` | `clear()` Sets the host address to 0.0.0.0.
`QHostAddress` | `clone()` This method is reimplemented for internal reasons
`boolean` | `isNull()` Returns true if this host address is null (INADDR_ANY or in6addr_any).
`QAbstractSocket.NetworkLayerProtocol` | `protocol()` Returns the network layer protocol of the host address.
`void` | `readFrom(QDataStream arg__1)` Reads a QHostAddress
`java.lang.String` | `scopeId()` Returns the scope ID of an IPv6 address.
`void` | `setAddress(int ip4Addr)` Set the IPv4 address specified by `ip4Addr`.
`void` | `setAddress(QIPv6Address ip6Addr)` Sets the address of this QHostAddress to `ip6Addr`.
`boolean` | `setAddress(java.lang.String address)` Sets the IPv4 or IPv6 address specified by the string representation specified by `address` (e.g.
`void` | `setScopeId(java.lang.String id)` Sets the IPv6 scope ID of the address to `id`.
`int` | `toIPv4Address()` Returns the IPv4 address as a number.
`QIPv6Address` | `toIPv6Address()` Returns the IPv6 address as a Q_IPV6ADDR structure.
`java.lang.String` | `toString()` Returns a string representation of the `this QHostAddress`.
`void` | `writeTo(QDataStream arg__1)` Writes thisQHostAddress

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Constructor Detail

### QHostAddress

    public QHostAddress()

  Constructs a host address object with the IP address 0. .0.0.

See also:
  `clear()`.

### QHostAddress

    public QHostAddress(QHostAddress.SpecialAddress address)

  Constructs a QHostAddress object for `address`.

### QHostAddress

    public QHostAddress(QHostAddress copy)

  Constructs a copy of the given `address`.

### QHostAddress

    public QHostAddress(QIPv6Address ip6Addr)

  Creates a QHostAddress from the specified `ip6Addr` address.

### QHostAddress

    public QHostAddress(java.lang.String address)

  Constructs an IPv4 or IPv6 address based on the string `address` (e. ., "127.0.0.1").

See also:
  `setAddress()`.

### QHostAddress

    public QHostAddress(int ip4Addr)

  Constructs a host address object with the IPv4 address `ip4Addr`.

Method Detail

### clear

    public final void clear()

  Sets the host address to 0.0.0.0.

### isNull

    public final boolean isNull()

  Returns true if this host address is null (INADDR_ANY or in6addr_any). The default constructor creates a null address, and that address is not valid for any host or interface.

### writeTo

    public final void writeTo(QDataStream arg__1)

  Writes thisQHostAddress

### readFrom

    public final void readFrom(QDataStream arg__1)

  Reads a QHostAddress

### protocol

    public final QAbstractSocket.NetworkLayerProtocol protocol()

  Returns the network layer protocol of the host address.

### scopeId

    public final java.lang.String scopeId()

  Returns the scope ID of an IPv6 address. For IPv4 addresses, or if the address does not contain a scope ID, an empty QString is returned.

  The IPv6 scope ID specifies the scope of reachability for non-global IPv6 addresses, limiting the area in which the address can be used. All IPv6 addresses are associated with such a reachability scope. The scope ID is used to disambiguate addresses that are not guaranteed to be globally unique.

  IPv6 specifies the following four levels of reachability:

  - 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.
  When using a link-local or site-local address for IPv6 connections, you must specify the scope ID. The scope ID for a link-local address is usually the same as the interface name (e.g., "eth0", "en1") or number (e.g., "1", "2").

See also:
  `setScopeId()`.

### setAddress

    public final void setAddress(QIPv6Address ip6Addr)

  Sets the address of this QHostAddress to `ip6Addr`.

### setAddress

    public final boolean setAddress(java.lang.String address)

  Sets the IPv4 or IPv6 address specified by the string representation specified by `address` (e.g. "127.0.0.1"). Returns true and sets the address if the address was successfully parsed; otherwise returns false.

### setAddress

    public final void setAddress(int ip4Addr)

  Set the IPv4 address specified by `ip4Addr`.

### setScopeId

    public final void setScopeId(java.lang.String id)

  Sets the IPv6 scope ID of the address to `id`. If the address protocol is not IPv6, this function does nothing.

See also:
  `scopeId()`.

### toIPv4Address

    public final int toIPv4Address()

  Returns the IPv4 address as a number.

  For example, if the address is 127.0.0.1, the returned value is 2130706433 (i.e. 0x7f000001).

  This value is only valid if isIp4Addr() returns true.

See also:
  `toString()`.

### toIPv6Address

    public final QIPv6Address toIPv6Address()

  Returns the IPv6 address as a Q_IPV6ADDR structure. The structure consists of 16 unsigned characters.

              QIPv6Address addr = hostAddr.toIPv6Address();
              // addr contains 16 unsigned characters

              for (int i = 0; i < 16; ++i) {
                  // process addr.c[i]
              }

  This value is only valid if isIPv6Address() returns true.

See also:
  `toString()`.

### toString

    public final java.lang.String toString()

  Returns a string representation of the `this QHostAddress`.

  Overrides:
    `toString` in class `java.lang.Object`

### clone

    public QHostAddress clone()

  This method is reimplemented for internal reasons

  Overrides:
    `clone` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD