The problem is simply that Lazarus will always raise an exception even if it is cought. Take the following code:
type
EGotoReplacement = class(Exception);
procedure GotoReplacementExample;
begin
try
while true do
begin
// Do something
if ExitCondition then raise EGotoReplacement;
end;
except on E: GotoReplacement do;
end;
// Do something after the loop
end;
If you run this code normally, the try-except works pretty much exactly like a goto:
procedure GotoExample;
label EndOfLoop;
begin
while true do
begin
// Do something
if ExitCondition then goto EndOfLoop;
end;
EndOfLoop:
// Do something after the loop
end;
But if you run it in Lazarus, Lazarus will instead pop up a window telling you that an EndOfLoop exception was raised.
This means exceptions that are part of the control flow of the program, can get really annoying really fast.
The ssockets library is built in a way that when there is no data available, instead of just returning some empty value, instead an exception is raised. This exception is then caught again to handle the non availability (e.g. by doing a sleep/idle loop). So it's a deviation from expected control flow i.e. an Exception, but it is handled so it is not an error, and therefore does not need to notify the user.
BUT: Lazarus does not know if it needs to notify the user or not, so it always notifies you.
How to solve this: Two options 1. don't make the listen socket non blocking. Just have it running in it's own thread. As there will always ever only be one listening socket, thats not an issue.
Option 2: Click the checkbox that says "Ignore exceptions of this type" then Lazarus will skip all non blocking exceptions and not pop up anymore
PS: The example above might seem stupid and a convoluted use of exceptions, but I have actually used this once in Java, as Java does not have a goto statement and I needed a goto statement