HotKeySet("{ESC}", "Terminate") $ConnectedSocket = -1 TCPStartup() $ConnectedSocket = TCPConnect("127.0.0.1", 5555) $counter = 0 While 1 $counter = $counter + 1 $text = "Transmission number " & $counter ConsoleWrite("Sending: " & $text & @CRLF) TCPSend($ConnectedSocket, StringToBinary($text, 4)) If @error Then ;try to reconnect everytime we notice the connection is lost $ConnectedSocket = TCPConnect("127.0.0.1", 5555) EndIf Sleep(1000) WEnd Func Terminate() If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket) TCPShutdown() ; Close the TCP service. Exit 0 EndFunc ;==>Terminate