implements possiblity to select host by name and not only by IP address (of course, selecting a host by IP address is still possible)
This commit is contained in:
parent
4cb4cade33
commit
d8fabf2e52
3 changed files with 32 additions and 10 deletions
|
@ -88,12 +88,26 @@ bool CClient::SetServerAddr ( QString strNAddr )
|
||||||
{
|
{
|
||||||
QHostAddress InetAddr;
|
QHostAddress InetAddr;
|
||||||
|
|
||||||
if ( InetAddr.setAddress ( strNAddr ) )
|
// first try if this is an IP number an can directly applied to QHostAddress
|
||||||
|
if ( !InetAddr.setAddress ( strNAddr ) )
|
||||||
{
|
{
|
||||||
// the server port is fixed and always the same
|
|
||||||
Channel.SetAddress ( CHostAddress ( InetAddr, LLCON_PORT_NUMBER ) );
|
|
||||||
|
|
||||||
return true;
|
// TODO implement the IP number query with QT objects (this is not possible with
|
||||||
|
// QT 2 so we have to implement a workaround solution here
|
||||||
|
|
||||||
|
// it was no vaild IP address, try to get host by name, assuming
|
||||||
|
// that the string contains a valid host name string
|
||||||
|
const hostent* HostInf = gethostbyname ( strNAddr.latin1() );
|
||||||
|
|
||||||
|
if ( HostInf )
|
||||||
|
{
|
||||||
|
uint32_t dwIPNumber;
|
||||||
|
|
||||||
|
// copy IP address of first found host in host list
|
||||||
|
memcpy ( (char*) &dwIPNumber, HostInf->h_addr_list[0], sizeof ( dwIPNumber ) );
|
||||||
|
|
||||||
|
// apply IP address to QT object (change byte order, too)
|
||||||
|
InetAddr.setAddress ( htonl ( dwIPNumber ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -101,6 +115,12 @@ bool CClient::SetServerAddr ( QString strNAddr )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// apply address (the server port is fixed and always the same)
|
||||||
|
Channel.SetAddress ( CHostAddress ( InetAddr, LLCON_PORT_NUMBER ) );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void CClient::OnProtocolStatus ( bool bOk )
|
void CClient::OnProtocolStatus ( bool bOk )
|
||||||
{
|
{
|
||||||
// show protocol status in GUI
|
// show protocol status in GUI
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
#else
|
#else
|
||||||
# include "../linux/sound.h"
|
# include "../linux/sound.h"
|
||||||
# include <sched.h>
|
# include <sched.h>
|
||||||
|
# include <socket.h>
|
||||||
|
# include <netdb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ BSC32=bscmake.exe
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
LINK32=link.exe
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||||
# ADD LINK32 winmm.lib $(QTDIR)\lib\qt-mt230nc.lib $(QTDIR)\lib\qtmain.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
# ADD LINK32 ws2_32.lib winmm.lib $(QTDIR)\lib\qt-mt230nc.lib $(QTDIR)\lib\qtmain.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "llcon - Win32 Debug"
|
!ELSEIF "$(CFG)" == "llcon - Win32 Debug"
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ BSC32=bscmake.exe
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
LINK32=link.exe
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||||
# ADD LINK32 winmm.lib $(QTDIR)\lib\qt-mt230nc.lib $(QTDIR)\lib\qtmain.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
# ADD LINK32 ws2_32.lib winmm.lib $(QTDIR)\lib\qt-mt230nc.lib $(QTDIR)\lib\qtmain.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||||
|
|
||||||
!ENDIF
|
!ENDIF
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue