I find that when eMule try to login to a server in the serverlist, it first creates a serversocket. If it cannot login to this server, it will try to login to another server in the serverlist, and it then creates another serversocket. But I wander how to deal with the first serversocket. I want to just create one serversocket for login to a server. Or ,I can say, I want to delete the first serversocket before I create another socket. Is it more reasonable? And how can I do this?
Page 1 of 1
How To Create Just One Socket For Serversocket?
#2
Posted 10 February 2006 - 08:22 PM
janequeen, on Feb 9 2006, 10:25 PM, said:
I find that when eMule try to login to a server in the serverlist, it first creates a serversocket. If it cannot login to this server, it will try to login to another server in the serverlist, and it then creates another serversocket. But I wander how to deal with the first serversocket. I want to just create one serversocket for login to a server. Or ,I can say, I want to delete the first serversocket before I create another socket. Is it more reasonable? And how can I do this?
I have only had a quick five minute look at the code so please forgive any mistakes:
So in void CServerSocket::OnConnect(int nErrorCode)
void CServerSocket::OnConnect(int nErrorCode) said:
case WSAEADDRNOTAVAIL:
case WSAECONNREFUSED:
//case WSAENETUNREACH: // let this error default to 'fatal error' as it does not inrease the server's failed count
case WSAETIMEDOUT:
case WSAEADDRINUSE:
if (thePrefs.GetVerbose())
DebugLogError(_T("Failed to connect to server %s; %s"), cur_server->GetAddress(), GetFullErrorMessage(nErrorCode));
m_bIsDeleting = true;
SetConnectionState(CS_SERVERDEAD);
serverconnect->DestroySocket(this);
return;
Note:
Quote
in EMSocket.h
class CEMSocket : public CAsyncSocketEx, public ThrottledFileSocket
in ServerSocket.h
class CServerSocket : public CEMSocket
class CEMSocket : public CAsyncSocketEx, public ThrottledFileSocket
in ServerSocket.h
class CServerSocket : public CEMSocket
OnConnect(int nErrorCode)

#3
Posted 12 February 2006 - 11:02 AM
Well, you can't reuse the socket, since sockets are per-connection, so just to switch to the IP of another server, you have to create a new socket.
As for deleting the old, isn't it done automatically already(provided the the old isn't still attemptint to connect)?
As for deleting the old, isn't it done automatically already(provided the the old isn't still attemptint to connect)?
This post has been edited by SlugFiller: 11 March 2006 - 08:41 PM
Why haven't you clicked yet?
SlugFiller rule #1: Unsolicited PMs is the second most efficient method to piss me off.
SlugFiller rule #2: The first most efficient method is unsolicited eMails.
SlugFiller rule #3: If it started in a thread, it should end in the same thread.
SlugFiller rule #4: There is absolutely no reason to perform the same discussion twice in parallel, especially if one side is done via PM.
SlugFiller rule #5: Does it say "Group: Moderators" under my name? No? Then stop telling me about who you want to ban! I really don't care! Go bother a moderator.
SlugFiller rule #6: I can understand English, Hebrew, and a bit of Japanese(standard) and Chinese(mandarin), but if you speak to me in anything but English, do expect to be utterly ignored, at best.
SlugFiller rule #1: Unsolicited PMs is the second most efficient method to piss me off.
SlugFiller rule #2: The first most efficient method is unsolicited eMails.
SlugFiller rule #3: If it started in a thread, it should end in the same thread.
SlugFiller rule #4: There is absolutely no reason to perform the same discussion twice in parallel, especially if one side is done via PM.
SlugFiller rule #5: Does it say "Group: Moderators" under my name? No? Then stop telling me about who you want to ban! I really don't care! Go bother a moderator.
SlugFiller rule #6: I can understand English, Hebrew, and a bit of Japanese(standard) and Chinese(mandarin), but if you speak to me in anything but English, do expect to be utterly ignored, at best.
#4
Posted 14 February 2006 - 01:46 AM
SlugFiller, on Feb 12 2006, 11:02 AM, said:
Thank you! I find that eMule always creates a new serversocket before it destroys the old one. I just worried something would be wrong in the interval that two sockets alive.
Page 1 of 1