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
|
// download URL
|
||||||
#define LLCON_DOWNLOAD_URL "http://sourceforge.net/projects/llcon/files"
|
#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
|
// defined port number for client and server
|
||||||
#if ( SYSTEM_FRAME_SIZE_SAMPLES == 64 )
|
#if ( SYSTEM_FRAME_SIZE_SAMPLES == 64 )
|
||||||
# define LLCON_DEFAULT_PORT_NUMBER 22064 // different port number for 64 samples frame size version
|
# 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()
|
CHostAddress NetworkUtil::GetLocalAddress()
|
||||||
{
|
{
|
||||||
QTcpSocket socket;
|
QTcpSocket socket;
|
||||||
socket.connectToHost("8.8.8.8", 53); // google DNS, or something else reliable
|
socket.connectToHost( WELL_KNOWN_HOST, WELL_KNOWN_PORT );
|
||||||
if (socket.waitForConnected()) {
|
if (socket.waitForConnected( IP_LOOKUP_TIMEOUT )) {
|
||||||
return CHostAddress( socket.localAddress(), 0 );
|
return CHostAddress( socket.localAddress(), 0 );
|
||||||
} else {
|
} else {
|
||||||
qWarning()
|
qWarning()
|
||||||
|
|
Loading…
Add table
Reference in a new issue