mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 23:12:16 +02:00
allow a blocking lookup of IP address in HifiSockAddr
This commit is contained in:
parent
acef1b868c
commit
74753e5b8b
3 changed files with 12 additions and 10 deletions
|
@ -96,17 +96,14 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
|||
assignmentServerPort =
|
||||
argumentVariantMap.value(CUSTOM_ASSIGNMENT_SERVER_PORT_OPTION).toString().toUInt();
|
||||
}
|
||||
|
||||
HifiSockAddr assignmentServerSocket(DEFAULT_ASSIGNMENT_SERVER_HOSTNAME, assignmentServerPort);
|
||||
|
||||
// check for an overriden assignment server hostname
|
||||
if (argumentVariantMap.contains(CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION)) {
|
||||
_assignmentServerHostname = argumentVariantMap.value(CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION).toString();
|
||||
|
||||
// change the hostname for our assignment server
|
||||
assignmentServerSocket = HifiSockAddr(_assignmentServerHostname, assignmentServerSocket.getPort());
|
||||
_assignmentServerHostname = argumentVariantMap.value(CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION).toString();
|
||||
}
|
||||
|
||||
HifiSockAddr assignmentServerSocket(_assignmentServerHostname, assignmentServerPort, true);
|
||||
nodeList->setAssignmentServerSocket(assignmentServerSocket);
|
||||
|
||||
qDebug() << "Assignment server socket is" << assignmentServerSocket;
|
||||
|
|
|
@ -36,15 +36,20 @@ HifiSockAddr::HifiSockAddr(const HifiSockAddr& otherSockAddr) {
|
|||
_port = otherSockAddr._port;
|
||||
}
|
||||
|
||||
HifiSockAddr::HifiSockAddr(const QString& hostname, quint16 hostOrderPort) :
|
||||
HifiSockAddr::HifiSockAddr(const QString& hostname, quint16 hostOrderPort, bool shouldBlockForLookup) :
|
||||
_address(hostname),
|
||||
_port(hostOrderPort)
|
||||
{
|
||||
// if we parsed an IPv4 address out of the hostname, don't look it up
|
||||
if (_address.protocol() != QAbstractSocket::IPv4Protocol) {
|
||||
// sync lookup the IP by the hostname
|
||||
int lookupID = QHostInfo::lookupHost(hostname, this, SLOT(handleLookupResult(QHostInfo)));
|
||||
qDebug() << "Looking up IP address for hostname" << hostname << "- lookup ID is" << lookupID;
|
||||
// lookup the IP by the hostname
|
||||
if (shouldBlockForLookup) {
|
||||
QHostInfo result = QHostInfo::fromName(hostname);
|
||||
handleLookupResult(result);
|
||||
} else {
|
||||
int lookupID = QHostInfo::lookupHost(hostname, this, SLOT(handleLookupResult(QHostInfo)));
|
||||
qDebug() << "Looking up IP address for hostname" << hostname << "- lookup ID is" << lookupID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
HifiSockAddr();
|
||||
HifiSockAddr(const QHostAddress& address, quint16 port);
|
||||
HifiSockAddr(const HifiSockAddr& otherSockAddr);
|
||||
HifiSockAddr(const QString& hostname, quint16 hostOrderPort);
|
||||
HifiSockAddr(const QString& hostname, quint16 hostOrderPort, bool shouldBlockForLookup = false);
|
||||
HifiSockAddr(const sockaddr* sockaddr);
|
||||
|
||||
bool isNull() const { return _address.isNull() && _port == 0; }
|
||||
|
|
Loading…
Reference in a new issue