I have application that connects to a controller via serial port as well as by Ethernet. Controller continuously throws data to PC. I am writing application in C#. I have created SerialPort object in c# and receiving data in dataReceived method. Similarly for Ethernet I have used TCPListener and its method startAcceptClient to accept connections from client.
Now, my question is if the controller is powered off or the cable removed from the PC; How to detect these events in the application?