Tune IP look up code
This commit is contained in:
parent
2d59e869bc
commit
942bdde3a5
2 changed files with 8 additions and 2 deletions
|
@ -110,6 +110,12 @@ LED bar: lbr
|
|||
// download URL
|
||||
#define LLCON_DOWNLOAD_URL "http://sourceforge.net/projects/llcon/files"
|
||||
|
||||
// determining server internal address uses well-known host and port
|
||||
// (Google DNS, or something else reliable)
|
||||
#define WELL_KNOWN_HOST "8.8.8.8" // Google
|
||||
#define WELL_KNOWN_PORT 53 // DNS
|
||||
#define IP_LOOKUP_TIMEOUT 500 // ms
|
||||
|
||||
// defined port number for client and server
|
||||
#if ( SYSTEM_FRAME_SIZE_SAMPLES == 64 )
|
||||
# define LLCON_DEFAULT_PORT_NUMBER 22064 // different port number for 64 samples frame size version
|
||||
|
|
|
@ -893,8 +893,8 @@ bool NetworkUtil::ParseNetworkAddress ( QString strAddress,
|
|||
CHostAddress NetworkUtil::GetLocalAddress()
|
||||
{
|
||||
QTcpSocket socket;
|
||||
socket.connectToHost("8.8.8.8", 53); // google DNS, or something else reliable
|
||||
if (socket.waitForConnected()) {
|
||||
socket.connectToHost( WELL_KNOWN_HOST, WELL_KNOWN_PORT );
|
||||
if (socket.waitForConnected( IP_LOOKUP_TIMEOUT )) {
|
||||
return CHostAddress( socket.localAddress(), 0 );
|
||||
} else {
|
||||
qWarning()
|
||||
|
|
Loading…
Reference in a new issue