[solved] Indy Telnet socket error 10054 lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- BlueIcaro · 2018-02-03 22:37 Hello, I playing with idTelnetclient Component. It's works nice. But when the server close the connection my program doesn't know it. And when I send data again I got a SocketError 10054. I tried to catch it but It doesn't work. Code: [Select] if IdTelnet1.Connected then   begin     Try     IdTelnet1.SendString(Edit1.Text+#10+#13);     Except on E:EIdSocketError do        ShowMessage('Fail');     end;   end   else   begin     Memo1.Lines.Add ('********** Disconected');   end;      How Can I handle this error on my program? Indy version is: 10.6.2.0 And I use Lazarus 1.8 in W7 Thanks /BlueIcaro ---------------------------------------------------------------------- Remy Lebeau · 2018-02-06 00:47 Quote from: BlueIcaro on February 03, 2018, 11:37:09 pmwhen the server close the connection my program doesn't know it. TIdTelnet uses an internal worker thread to read data from the server.  If the connection is lost, that thread will (eventually) detect it, firing the TIdTelnet.OnStatus event with the Status parameter set to hsDisconnected. Quote from: BlueIcaro on February 03, 2018, 11:37:09 pmAnd when I send data again I got a SocketError 10054. That is WSAECONNRESET, which makes sense if you try to send on a dead connection. Quote from: BlueIcaro on February 03, 2018, 11:37:09 pmI tried to catch it but It doesn't work. That is because IdTelnet.SendString() has an internal try/except block around each character it sends (I don't know why).  If you want to catch the error in your own code, you will have to use TIdTelnet.SendCh() instead (note that SendCh() calls Connected() internally): Code: [Select]s := Edit1.Text+#10+#13; try   for i := 1 to Length(s) do     IdTelnet1.SendCh(s[i]); except   on E: EIdSocketError do     ShowMessage('Fail'); end; ---------------------------------------------------------------------- BlueIcaro · 2018-02-25 08:13 Thanks, it's works! /BlueIcaro