Board index » cppbuilder » EidClosedSocket with message 'Disconnected'

EidClosedSocket with message 'Disconnected'


2007-11-26 05:05:08 PM
cppbuilder104
Hi all,
I am using Indy 9.0.4. Currently I am working on TCPServer and facing problem to disconnect all connected client.
"EidClosedSocket with message 'Disconnected'" exception will show when I try to disconnect all connected client and set active to false or delete object.
tcpServer->Bindings->Items[0]->CloseSocket();
tcpServer->Active = false;
Any suggestion to gracefully disconnect all connected clients?
Thanks.
 
 

Re:EidClosedSocket with message 'Disconnected'

"SKLIM" < XXXX@XXXXX.COM >wrote in message
Quote
I am using Indy 9.0.4. Currently I am working on TCPServer and
facing problem to disconnect all connected client.
That is because you are disconnecting them wrong. You are closing the
Binding itself, not the clients that are connected to it. You would have to
loop through the entries in the server's ActiveThreads list, calling
DisconnectSocket() on each one individually.
Quote
Any suggestion to gracefully disconnect all connected clients?
You should not be disconnecting them manually to begin with. Setting the
Active property to false by itself will internally disconnect all active
clients for you.
Gambit
 

Re:EidClosedSocket with message 'Disconnected'

"Remy Lebeau \(TeamB\)" < XXXX@XXXXX.COM >wrote:
Quote

"SKLIM" < XXXX@XXXXX.COM >wrote in message
news:474a9a54$ XXXX@XXXXX.COM ...

>I am using Indy 9.0.4. Currently I am working on TCPServer and
>facing problem to disconnect all connected client.

That is because you are disconnecting them wrong. You are closing the
Binding itself, not the clients that are connected to it. You would have to
loop through the entries in the server's ActiveThreads list, calling
DisconnectSocket() on each one individually.

Before I tried with the binding, I did call DisconnectSocket for each activeThread and they have the same exception. The following are the code:
TList *lstThread = tcpServer->Threads->LockList();
int iConnectedClientCount = lstThread->Count;
TIdPeerThread *AThread;
for(int i=0; i<iConnectedClientCount; i++){
AThread = (TIdPeerThread *)lstThread->Items[i];
try{
AThread->Connection->DisconnectSocket();
}
catch(const Exception &e){
continue;
}
}
tcpServer->Threads->UnlockList();
Exception shows when DisconnectSocket is called.
Quote
>Any suggestion to gracefully disconnect all connected clients?

You should not be disconnecting them manually to begin with. Setting the
Active property to false by itself will internally disconnect all active
clients for you.
Set the active property to false has the same exception.
 

{smallsort}

Re:EidClosedSocket with message 'Disconnected'

"SKLIM" < XXXX@XXXXX.COM >wrote in message
Quote
Before I tried with the binding, I did call DisconnectSocket for
each activeThread and they have the same exception.
Then those clients were already disconnected, and you are already trapping
the exception and moving on to the next client. That is all you can do.
Gambit