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.
"SKLIM" wrote in message
news:474b8c73$1@newsgroups.borland.com...
> 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
"Remy Lebeau \(TeamB\)" wrote:
>
>"SKLIM" wrote in message
>news:474a9a54$1@newsgroups.borland.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; iItems[i];
try{
AThread->Connection->DisconnectSocket();
}
catch(const Exception &e){
continue;
}
}
tcpServer->Threads->UnlockList();
Exception shows when DisconnectSocket is called.
>> 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.
"SKLIM" wrote in message
news:474a9a54$1@newsgroups.borland.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.
> 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