This is normal behavior.
TIdTCPServer is a multi-threaded component. When a client connects, it runs in its own worker thread. The
TIdTCPServer.OnExecute event is fired in the context of that thread in a continuous loop for the lifetime of the socket connection.
After the client sends the image stream, it disconnects from the server.
After the server reads the image stream, it exits the
OnExecute event handler. The handler will be fired again, calling
ReadLn(), which will detect the disconnect and raise the
This is normal behavior. Just let the exception escape the event handler. Don't catch it (or, if you do, be sure to re-raise it).
TIdTCPServer will handle the exception for you, closing the client socket and stopping the thread that manages the socket.
FYI, on a side note, the default image format of FMX's
TBitmap.SaveTo...() methods is PNG, not BMP.