LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP - when connection is lost

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:

http://blogs.technet.com/b/nettracer/archive/2010/06/03/things-that-you-may-want-to-know-about-tcp-k...

when OS detects that connection is lost will my tcp read return an error?

0 Kudos
Message 1 of 3
(3,124 Views)
Can you show your code or at least the LabVIEW side of it? Also, are you running any higher-level protocol on top of the TCP/IP? Like maybe modbus?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 3
(3,060 Views)

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-...

0 Kudos
Message 3 of 3
(3,052 Views)