DelphiBuilder / NetCom7

The fastest communications possible. Delphi rulez.
MIT License
174 stars 43 forks source link

How to gracefully close connection without exceptions ? #6

Closed MauricDaniel closed 4 years ago

MauricDaniel commented 4 years ago

I find that when shutting down clients and disconnecting by setting Active to false secondary thread raises an exception.

It happens in function ReadableAnySocket:

    if iRes = SOCKET_ERROR then
      raise TncLineException.Create('Socket error');

It's caught and swallowed by TncClientProcessor.ReadableSocket, but still doesn't feel right.

It's called from TncClientProcessor.SocketProcess which would avoid the exception if it was Terminated, but it's not.

What is the proper shutdown strategy to avoid this exception ?

DelphiBuilder commented 4 years ago

Dear Daniel,

the NetCom7 suite has been modified. The way the sockets (every sockets) pickup the disconnect is when reading data... Unfortunately I made that exception non-silent whereas it should have been silent. I have now changed this. You will find no exceptions raised when closing sockets... Thank you for the suggestion.

regards, Bill