1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
'\" t
.TH QHostAddress 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QHostAddress \- IP address
.SH SYNOPSIS
\fC#include <ntqhostaddress.h>\fR
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQHostAddress\fR ()"
.br
.ti -1c
.BI "\fBQHostAddress\fR ( TQ_UINT32 ip4Addr )"
.br
.ti -1c
.BI "\fBQHostAddress\fR ( TQ_UINT8 * ip6Addr )"
.br
.ti -1c
.BI "\fBQHostAddress\fR ( const Q_IPV6ADDR & ip6Addr )"
.br
.ti -1c
.BI "\fBQHostAddress\fR ( const QHostAddress & address )"
.br
.ti -1c
.BI "virtual \fB~QHostAddress\fR ()"
.br
.ti -1c
.BI "QHostAddress & \fBoperator=\fR ( const QHostAddress & address )"
.br
.ti -1c
.BI "void \fBsetAddress\fR ( TQ_UINT32 ip4Addr )"
.br
.ti -1c
.BI "void \fBsetAddress\fR ( TQ_UINT8 * ip6Addr )"
.br
.ti -1c
.BI "bool \fBsetAddress\fR ( const TQString & address )"
.br
.ti -1c
.BI "bool isIp4Addr () const \fI(obsolete)\fR"
.br
.ti -1c
.BI "TQ_UINT32 ip4Addr () const \fI(obsolete)\fR"
.br
.ti -1c
.BI "bool \fBisIPv4Address\fR () const"
.br
.ti -1c
.BI "TQ_UINT32 \fBtoIPv4Address\fR () const"
.br
.ti -1c
.BI "bool \fBisIPv6Address\fR () const"
.br
.ti -1c
.BI "Q_IPV6ADDR \fBtoIPv6Address\fR () const"
.br
.ti -1c
.BI "TQString \fBtoString\fR () const"
.br
.ti -1c
.BI "bool \fBoperator==\fR ( const QHostAddress & other ) const"
.br
.ti -1c
.BI "bool \fBisNull\fR () const"
.br
.in -1c
.SH DESCRIPTION
The QHostAddress class provides an IP address.
.PP
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.
.PP
QHostAddress is normally used with the classes QSocket, QServerSocket and QSocketDevice to set up a server or to connect to a host.
.PP
Host addresses may be set with setAddress() and retrieved with ip4Addr() or toString().
.PP
See also QSocket, QServerSocket, QSocketDevice, and Input/Output and Networking.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QHostAddress::QHostAddress ()"
Creates a host address object with the IP address 0.0.0.0.
.SH "QHostAddress::QHostAddress ( TQ_UINT32 ip4Addr )"
Creates a host address object for the IPv4 address \fIip4Addr\fR.
.SH "QHostAddress::QHostAddress ( TQ_UINT8 * ip6Addr )"
Creates a host address object with the specified IPv6 address.
.PP
\fIip6Addr\fR must be a 16 byte array in network byte order (high-order byte first).
.SH "QHostAddress::QHostAddress ( const Q_IPV6ADDR & ip6Addr )"
Creates a host address object with the IPv6 address, \fIip6Addr\fR.
.SH "QHostAddress::QHostAddress ( const QHostAddress & address )"
Creates a copy of \fIaddress\fR.
.SH "QHostAddress::~QHostAddress ()\fC [virtual]\fR"
Destroys the host address object.
.SH "TQ_UINT32 QHostAddress::ip4Addr () const"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
Use toIPv4Address() instead.
.SH "bool QHostAddress::isIPv4Address () const"
Returns TRUE if the host address represents an IPv4 address; otherwise returns FALSE.
.SH "bool QHostAddress::isIPv6Address () const"
Returns TRUE if the host address represents an IPv6 address; otherwise returns FALSE.
.SH "bool QHostAddress::isIp4Addr () const"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
Use isIPv4Address() instead.
.SH "bool QHostAddress::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.
.SH "QHostAddress & QHostAddress::operator= ( const QHostAddress & address )"
Assigns another host address object \fIaddress\fR to this object and returns a reference to this object.
.SH "bool QHostAddress::operator== ( const QHostAddress & other ) const"
Returns TRUE if this host address is the same as \fIother\fR; otherwise returns FALSE.
.SH "void QHostAddress::setAddress ( TQ_UINT32 ip4Addr )"
Set the IPv4 address specified by \fIip4Addr\fR.
.SH "void QHostAddress::setAddress ( TQ_UINT8 * ip6Addr )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Set the IPv6 address specified by \fIip6Addr\fR.
.PP
\fIip6Addr\fR must be a 16 byte array in network byte order (high-order byte first).
.SH "bool QHostAddress::setAddress ( const TQString & address )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Sets the IPv4 or IPv6 address specified by the string representation \fIaddress\fR (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.
.SH "TQ_UINT32 QHostAddress::toIPv4Address () const"
Returns the IPv4 address as a number.
.PP
For example, if the address is 127.0.0.1, the returned value is 2130706433 (i.e. 0x7f000001).
.PP
This value is only valid when isIp4Addr() returns TRUE.
.PP
See also toString().
.SH "Q_IPV6ADDR QHostAddress::toIPv6Address () const"
Returns the IPv6 address as a Q_IPV6ADDR structure. The structure consists of 16 unsigned characters.
.PP
.nf
.br
Q_IPV6ADDR addr = hostAddr.ip6Addr();
.br
// addr.c[] contains 16 unsigned characters
.br
.br
for (int i = 0; i < 16; ++i) {
.br
// process addr.c[i]
.br
}
.br
.fi
.PP
This value is only valid when isIPv6Address() returns TRUE.
.PP
See also toString().
.SH "TQString QHostAddress::toString () const"
Returns the address as a string.
.PP
For example, if the address is the IPv4 address 127.0.0.1, the returned string is "127.0.0.1".
.PP
See also ip4Addr().
.SH "SEE ALSO"
.BR http://doc.trolltech.com/ntqhostaddress.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive TQt documentation is provided in HTML format; it is
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (tqhostaddress.3qt) and the Qt
version (3.3.8).
|