Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

TQHostAddress Class Reference
[network module]

The TQHostAddress class provides an IP address. More...

#include <qhostaddress.h>

List of all member functions.

Public Members


Detailed Description

The TQHostAddress class provides an IP address.

This class contains an IP address in a platform and protocol independent manner. It stores both IPv4 and IPv6 addresses in a way that you can easily access on any platform.

TQHostAddress is normally used with the classes TQSocket, TQServerSocket and TQSocketDevice to set up a server or to connect to a host.

Host addresses may be set with setAddress() and retrieved with ip4Addr() or toString().

See also TQSocket, TQServerSocket, TQSocketDevice, and Input/Output and Networking.


Member Function Documentation

TQHostAddress::TQHostAddress ()

Creates a host address object with the IP address 0.0.0.0.

TQHostAddress::TQHostAddress ( Q_UINT32 ip4Addr )

Creates a host address object for the IPv4 address ip4Addr.

TQHostAddress::TQHostAddress ( Q_UINT8 * ip6Addr )

Creates a host address object with the specified IPv6 address.

ip6Addr must be a 16 byte array in network byte order (high-order byte first).

TQHostAddress::TQHostAddress ( const Q_IPV6ADDR & ip6Addr )

Creates a host address object with the IPv6 address, ip6Addr.

TQHostAddress::TQHostAddress ( const TQHostAddress & address )

Creates a copy of address.

TQHostAddress::~TQHostAddress () [virtual]

Destroys the host address object.

Q_UINT32 TQHostAddress::ip4Addr () const

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Use toIPv4Address() instead.

bool TQHostAddress::isIPv4Address () const

Returns TRUE if the host address represents an IPv4 address; otherwise returns FALSE.

bool TQHostAddress::isIPv6Address () const

Returns TRUE if the host address represents an IPv6 address; otherwise returns FALSE.

bool TQHostAddress::isIp4Addr () const

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Use isIPv4Address() instead.

bool TQHostAddress::isNull () const

Returns TRUE if this host address is null (INADDR_ANY or in6addr_any). The default constructor creates a null address, and that address isn't valid for any particular host or interface.

TQHostAddress & TQHostAddress::operator= ( const TQHostAddress & address )

Assigns another host address object address to this object and returns a reference to this object.

bool TQHostAddress::operator== ( const TQHostAddress & other ) const

Returns TRUE if this host address is the same as other; otherwise returns FALSE.

void TQHostAddress::setAddress ( Q_UINT32 ip4Addr )

Set the IPv4 address specified by ip4Addr.

void TQHostAddress::setAddress ( Q_UINT8 * ip6Addr )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Set the IPv6 address specified by ip6Addr.

ip6Addr must be a 16 byte array in network byte order (high-order byte first).

bool TQHostAddress::setAddress ( const TQString & address )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Sets the IPv4 or IPv6 address specified by the string representation address (e.g. "127.0.0.1"). Returns TRUE and sets the address if the address was successfully parsed; otherwise returns FALSE and leaves the address unchanged.

Q_UINT32 TQHostAddress::toIPv4Address () const

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 when isIp4Addr() returns TRUE.

See also toString().

Q_IPV6ADDR TQHostAddress::toIPv6Address () const

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

        Q_IPV6ADDR addr = hostAddr.ip6Addr();
        // addr.c[] contains 16 unsigned characters

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

This value is only valid when isIPv6Address() returns TRUE.

See also toString().

TQString TQHostAddress::toString () const

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".

See also ip4Addr().


This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.


Copyright © 2007 TrolltechTrademarks
TQt 3.3.8