03-28-2015 03:41 AM - edited 03-28-2015 03:48 AM
Hello,
I have problem understanding when connection is broken in ny case.
I have PLC connectd to PC by ethernet cable. I use TCP to exchange data between them. Tha works ok. PLC has function to close connection and that works good - tcp listen returns error 66 so I know that connection was closed.
When I unplug cable from pc or plc there is no error and I can still sent data using tcp write and that function won't return an error.
My understangind was that, when connection is closed or broken (like cable unplugged) tcp read will return an error.
So what will happen when connection is reestablished, my data will be transfered?
Could someone explain me how it works?
How can I detect that cable is unplugged?
I can ping plc and wait for response but is there other alternative?
There is keepalive parameter on windows that I think I can modify:
when OS detects that connection is lost will my tcp read return an error?
03-28-2015 04:43 PM
03-28-2015 06:13 PM
I thought there had been a recent thread about this, but I can't find it.
The operating system decides what to do when the cable is unplugged. It may keep connections open for some period of time, in case the cable is reconnected quickly. LabVIEW doesn't know anything about this; the TCP functions are just wrappers around the operating system functions. See, for example, http://stackoverflow.com/questions/14227007/howto-detect-that-a-network-cable-has-been-unplugged-in-...