support for client to connect server on different port number
This commit is contained in:
parent
11fb1dbacd
commit
59390f6d37
1 changed files with 13 additions and 1 deletions
|
@ -87,6 +87,18 @@ void CClient::OnNewConnection()
|
||||||
bool CClient::SetServerAddr ( QString strNAddr )
|
bool CClient::SetServerAddr ( QString strNAddr )
|
||||||
{
|
{
|
||||||
QHostAddress InetAddr;
|
QHostAddress InetAddr;
|
||||||
|
quint16 iNetPort = LLCON_PORT_NUMBER;
|
||||||
|
|
||||||
|
// parse input address for the type [IP address]:[port number]
|
||||||
|
QString strPort = strNAddr.section ( ":", 1, 1 );
|
||||||
|
if ( !strPort.isEmpty() )
|
||||||
|
{
|
||||||
|
// a colon is present in the address string, try to extract port number
|
||||||
|
iNetPort = strPort.toInt();
|
||||||
|
|
||||||
|
// extract address port before colon (should be actual internet address)
|
||||||
|
strNAddr = strNAddr.section ( ":", 0, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
// first try if this is an IP number an can directly applied to QHostAddress
|
// first try if this is an IP number an can directly applied to QHostAddress
|
||||||
if ( !InetAddr.setAddress ( strNAddr ) )
|
if ( !InetAddr.setAddress ( strNAddr ) )
|
||||||
|
@ -111,7 +123,7 @@ bool CClient::SetServerAddr ( QString strNAddr )
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply address (the server port is fixed and always the same)
|
// apply address (the server port is fixed and always the same)
|
||||||
Channel.SetAddress ( CHostAddress ( InetAddr, LLCON_PORT_NUMBER ) );
|
Channel.SetAddress ( CHostAddress ( InetAddr, iNetPort ) );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue