|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.network.QHostAddress
public class QHostAddress
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.
Nested Class Summary | |
---|---|
static class |
QHostAddress.SpecialAddress
Press link for info on QHostAddress.SpecialAddress |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I> |
Constructor Summary | |
---|---|
QHostAddress()
Constructs a host address object with the IP address 0.0.0.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 copy. |
|
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.g., "127.0.0.1"). |
Method Summary | |
---|---|
void |
clear()
Sets the host address to 0.0.0.0. |
boolean |
equals(java.lang.Object other)
|
static QHostAddress |
fromNativePointer(QNativePointer nativePointer)
This function returns the QHostAddress instance pointed to by nativePointer |
int |
hashCode()
|
boolean |
isNull()
Returns true if this host address is null (INADDR_ANY or in6addr_any). |
static QNativePointer |
nativePointerArray(QHostAddress[] array)
This function returns a QNativePointer that is pointing to the specified QHostAddress array. |
QAbstractSocket.NetworkLayerProtocol |
protocol()
Returns the network layer protocol of the host address. |
void |
readFrom(QDataStream arg__1)
Reads a QHostAddress from arg__1. |
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. "127.0.0.1"). |
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 the address as a string. |
void |
writeTo(QDataStream arg__1)
Writes thisQHostAddress to arg__1. |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class java.lang.Object |
---|
clone, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QHostAddress(java.lang.String address)
Constructs an IPv4 or IPv6 address based on the string address (e.g., "127.0.0.1").
public QHostAddress(QHostAddress copy)
Constructs a copy of the given copy.
public QHostAddress()
Constructs a host address object with the IP address 0.0.0.0.
public QHostAddress(int ip4Addr)
Constructs a host address object with the IPv4 address ip4Addr.
public QHostAddress(QIPv6Address ip6Addr)
public QHostAddress(QHostAddress.SpecialAddress address)
Constructs a QHostAddress object for address.
Method Detail |
---|
public final void clear()
Sets the host address to 0.0.0.0.
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.
public final void writeTo(QDataStream arg__1)
public final void readFrom(QDataStream arg__1)
public final QAbstractSocket.NetworkLayerProtocol protocol()
Returns the network layer protocol of the host address.
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:
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").
public final void setAddress(int ip4Addr)
Set the IPv4 address specified by ip4Addr.
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.
public final void setAddress(QIPv6Address ip6Addr)
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.
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.
public final QIPv6Address toIPv6Address()
Returns the IPv6 address as a Q_IPV6ADDR structure. The structure consists of 16 unsigned characters.
Q_IPV6ADDR addr = hostAddr.toIPv6Address(); // addr contains 16 unsigned characters for (int i = 0; i < 16; ++i) { // process addr[i] }
This value is only valid if isIPv6Address() returns true.
public final java.lang.String toString()
Returns the address as a string.
For example, if the address is the IPv4 address 127.0.0.1, the returned string is "127.0.0.1".
toString
in class java.lang.Object
public static QHostAddress fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.public static QNativePointer nativePointerArray(QHostAddress[] array)
array
- the array that the returned pointer will point to.
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |