sends a loginpacket to connect to the server, but
it writes the port to the packet twice (initial data + tag):
Quote
...
void CServerConnect::ConnectionEstablished() {
...
// send loginpacket
CSafeMemFile data(256);
data.WriteHash16(thePrefs.GetUserHash());
data.WriteUInt32(GetClientID());
data.WriteUInt16(thePrefs.GetPort());
uint32 tagcount = 5;
data.WriteUInt32(tagcount);
...
CTag tagPort(CT_PORT,thePrefs.GetPort());
tagPort.WriteTagToFile(&data);
...
}
...
void CServerConnect::ConnectionEstablished() {
...
// send loginpacket
CSafeMemFile data(256);
data.WriteHash16(thePrefs.GetUserHash());
data.WriteUInt32(GetClientID());
data.WriteUInt16(thePrefs.GetPort());
uint32 tagcount = 5;
data.WriteUInt32(tagcount);
...
CTag tagPort(CT_PORT,thePrefs.GetPort());
tagPort.WriteTagToFile(&data);
...
}
...
isn't that a little wasteful? can the tag be dropped?
btw, while we're at it, if the internet connection is down,
this class tries to reconnect, but i want to limit the attempts here:
Quote
...
CServerConnect::ConnectionFailed() {
...
switch (sender->GetConnectionState()) {
case CS_FATALERROR: {
bool autoretry = !singleconnecting;
StopConnectionTry();
if ((thePrefs.Reconnect()) && (autoretry) && (!m_idRetryTimer)) {
LogWarning(GetResString(IDS_RECONNECT), CS_RETRYCONNECTTIME);
VERIFY( (m_idRetryTimer= SetTimer(NULL, 0, 1000*CS_RETRYCONNECTTIME, RetryConnectTimer)) != NULL );
if (thePrefs.GetVerbose() && !m_idRetryTimer)
DebugLogError(_T("Failed to create 'server connect retry' timer - %s"),GetErrorMessage(GetLastError()));
}
break;
}
...
}
...
CServerConnect::ConnectionFailed() {
...
switch (sender->GetConnectionState()) {
case CS_FATALERROR: {
bool autoretry = !singleconnecting;
StopConnectionTry();
if ((thePrefs.Reconnect()) && (autoretry) && (!m_idRetryTimer)) {
LogWarning(GetResString(IDS_RECONNECT), CS_RETRYCONNECTTIME);
VERIFY( (m_idRetryTimer= SetTimer(NULL, 0, 1000*CS_RETRYCONNECTTIME, RetryConnectTimer)) != NULL );
if (thePrefs.GetVerbose() && !m_idRetryTimer)
DebugLogError(_T("Failed to create 'server connect retry' timer - %s"),GetErrorMessage(GetLastError()));
}
break;
}
...
}
...
that way eMule will not try to reconnect if the internet is still down
(and won't connect) and eMule will not delete all the servers in the list.
is that the way or should i do this in another place (function/class)?
Avi3k