45 #include "private/qnativesocketengine_p.h" 47 #include <private/qsystemlibrary_p.h> 69 #define QT_SOCKLEN_T int 70 #ifndef NI_MAXHOST // already defined to 1025 in ws2tcpip.h? 71 #define NI_MAXHOST 1024 85 static bool triedResolve =
false;
89 #if !defined(Q_OS_WINCE) 103 #if defined(Q_OS_WINCE) 111 case WSAHOST_NOT_FOUND:
128 #if defined(Q_OS_WINCE) 136 #if defined(QHOSTINFO_DEBUG) 137 qDebug(
"QHostInfoAgent::fromName(%p): looking up \"%s\" (IPv6 support is %s)",
151 sa = (sockaddr *)&sa4;
152 saSize =
sizeof(sa4);
153 memset(&sa4, 0,
sizeof(sa4));
154 sa4.sin_family = AF_INET;
157 sa = (sockaddr *)&sa6;
158 saSize =
sizeof(sa6);
159 memset(&sa6, 0,
sizeof(sa6));
169 struct hostent *ent = gethostbyaddr((
const char*)&addr,
sizeof(addr), AF_INET);
198 switch (p->ai_family) {
201 addr.
setAddress(ntohl(((sockaddr_in *) p->ai_addr)->sin_addr.s_addr));
225 hostent *ent = gethostbyname(aceHostname.
constData());
229 switch (ent->h_addrtype) {
231 for (p = ent->h_addr_list; *p != 0; p++) {
232 long *ip4Addr = (
long *) *p;
249 #if defined(QHOSTINFO_DEBUG) 251 qDebug(
"QHostInfoAgent::run(%p): error (%s)",
256 for (
int i = 0; i < addresses.
count(); ++i) {
257 if (i != 0) tmp +=
", ";
260 qDebug(
"QHostInfoAgent::run(%p): found %i entries: {%s}",
272 if (gethostname(hostName,
sizeof(hostName)) == -1)
274 hostName[
sizeof(hostName) - 1] =
'\0';
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Q_IPV6ADDR toIPv6Address() const
Returns the IPv6 address as a Q_IPV6ADDR structure.
#define QT_END_NAMESPACE
This macro expands to.
The QMutex class provides access serialization between threads.
void setErrorString(const QString &errorString)
Sets the human readable description of the error that occurred to str if the lookup failed...
The QByteArray class provides an array of bytes.
static freeaddrinfoProto local_freeaddrinfo
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
HostInfoError error() const
Returns the type of error that occurred if the host name lookup failed; otherwise returns NoError...
struct qt_in6_addr sin6_addr
int count(const T &t) const
Returns the number of occurrences of value in the list.
quint32 toIPv4Address() const
Returns the IPv4 address as a number.
The QString class provides a Unicode character string.
bool load(bool onlySystemDirectory=true)
QList< QHostAddress > addresses() const
Returns the list of IP addresses associated with hostName().
Q_CORE_EXPORT void qDebug(const char *,...)
int(__stdcall * getaddrinfoProto)(const char *, const char *, const qt_addrinfo *, qt_addrinfo **)
static QByteArray toAce(const QString &)
Returns the ASCII Compatible Encoding of the given domain name domain.
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
void setHostName(const QString &name)
Sets the host name of this QHostInfo to hostName.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
void setAddresses(const QList< QHostAddress > &addresses)
Sets the list of addresses in this QHostInfo to addresses.
QString hostName() const
Returns the name of the host whose IP addresses were looked up.
static getnameinfoProto local_getnameinfo
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
const T & at(int i) const
Returns the item at index position i in the list.
The QHostInfo class provides static functions for host name lookups.
QString toString() const
Returns the address as a string.
static QString localHostName()
Returns the host name of this machine.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
int(__stdcall * freeaddrinfoProto)(qt_addrinfo *)
void setError(HostInfoError error)
Sets the error type of this QHostInfo to error.
const char * constData() const
Returns a pointer to the data stored in the byte array.
static getaddrinfoProto local_getaddrinfo
static void resolveLibrary()
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
void * resolve(const char *symbol)
QAbstractSocket::NetworkLayerProtocol protocol() const
Returns the network layer protocol of the host address.
void setAddress(quint32 ip4Addr)
Set the IPv4 address specified by ip4Addr.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
static void translateWSAError(int error, QHostInfo *results)
QString errorString() const
If the lookup failed, this function returns a human readable description of the error; otherwise "Unk...
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
The QHostAddress class provides an IP address.
static QHostInfo fromName(const QString &hostName)
int(__stdcall * getnameinfoProto)(const sockaddr *, QT_SOCKLEN_T, const char *, DWORD, const char *, DWORD, int)