Mega Search
23.2 Million


Sign Up

Make a donation  
EidClosedSocket with message 'Disconnected'  
News Group: borland.public.cppbuilder.internet.socket

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.

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 26-Nov-2007, at 2:05 AM EST
From: sklim
 
Re: EidClosedSocket with message 'Disconnected'  
News Group: borland.public.cppbuilder.internet.socket
"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 



Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 27-Nov-2007, at 9:36 AM EST
From: Remy Lebeau \(TeamB\)
 
Re: EidClosedSocket with message 'Disconnected'  
News Group: borland.public.cppbuilder.internet.socket
"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.



Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 26-Nov-2007, at 7:18 PM EST
From: sklim
 
Re: EidClosedSocket with message 'Disconnected'  
News Group: borland.public.cppbuilder.internet.socket
"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 



Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 26-Nov-2007, at 9:35 AM EST
From: Remy Lebeau \(TeamB\)