0
Vote

public override void CheckForDisconnect should have a version that doesn't throw an exception.

description

The function "public override void CheckForDisconnect" needs to have a version that returns the connection status without throwing an exception.
 
Exceptions should not be used for normal control flow. This totally kills performance. There are even recommendations from Microsoft to use PerfMon to ensure that an excessive amount of exceptions are not being thrown and caught.
 
Example of bad code:
Indy.Sockets.Core.Socket.ReadBytes
 
                try {
                    // Read from stack until we have enough data
                    while (mInputBuffer.Size < byteCount) {
                        ReadFromSource(false);
                        CheckForDisconnect(true, true);
                    }
                } catch (ConnectionClosedGracefullyException) {
                }
 
 
I noticed this when running the old version of IndySockets with the debugger attached. My output window was filled with First Chance Excpetions that IndyScokets was throwing and catching.

comments