Re: [twsocket] Freeze on TWSocketServer close

2018-08-17 Thread Angus Robertson - Magenta Systems Ltd
> *Subject:* [twsocket] Freeze on TWSocketServer close
> *From:* Engi 
> *To:* "ICS support mailing," 
> *Date:* Fri, 17 Aug 2018 15:38:15 +0200
> 
> Hi,
> 
> My program (a service) hosts 4 TWSocketServers in main thread.
> Sometimes, when I ask the service to stop, the program freeze 
> after I call TWSocketServer Close function

You are assuming all sockets disconnect instantly and are the freeing
the component, when activity may still be happening.  

You should wait until there are zero clients on the server before
freeing it.  Stop listening first, so new clients can not connect while
you wait, at least one minute or more. 

Angus

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


[twsocket] Freeze on TWSocketServer close

2018-08-17 Thread Engi

Hi,

My program (a service) hosts 4 TWSocketServers in main thread.
Sometimes, when I ask the service to stop, the program freeze after I 
call TWSocketServer Close function, as if the function was waiting to 
regain control.
In this case, I have to restart my pc because a taskkill on .exe does 
not work.

Here is my code to stop the 4 servers :

    try
    {
    if (serveur != NULL)
    {
    if (serveur->State != wsClosed)
    {
    serveur->DisconnectAll();
    serveur->Shutdown(2);
    serveur->Close();
    }

    delete serveur;
    serveur = NULL;
    }
    }
    catch(...)
    {
    }

It's the same code for each server that I close one after the other.
Often, it's by closing the second server that program freeze.

Is there something wrong in my code ?

Thanks,
Nicolas

PS : I'm using ICS version 8.26 under C++ Builder XE
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be