LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP Connection lost in between TCP read operation

Hi all,

                Is there any method to check whether TCP connection is lost ? Actually in my program server may need to read the data for 44 minutes & i want to know that while reading say after 20 minutes connection is lost for unknown reasons. In that condition i should make sure that connection is estalished / lost. If in between this happens than i should inform user the same.

Any implementation of this type. 

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 1 of 11
(3,335 Views)

@Ranjeet_Singh wrote:

Hi all,

                Is there any method to check whether TCP connection is lost ? Actually in my program server may need to read the data for 44 minutes & i want to know that while reading say after 20 minutes connection is lost for unknown reasons. In that condition i should make sure that connection is estalished / lost. If in between this happens than i should inform user the same.

Any implementation of this type. 


There is no direct method other than the results of transmitting/receiving data. If you get an error 66 that would indicate that the connection has been closed by the other side. However, you will not get this until you try to send/receive data. If you are receiving data continuously you can looki for a timeout error (error 56). You may also get an error 52. The end result is that you need to check the error codes and then take whatever action you deem necessary.

 



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 11
(3,307 Views)

See i also got this idea but what happens if during transmission if network connection is lost than also it will be connected to netowork so it wont show the ERROR 66(This i verified by myself)

                                                                                                      As the other solution i cant send any data while i am receiciving the data i.e. inbetween read i cant write data. That is just not possible. 

                                                                                                        

Timeout error is not possible because this is running on the server so input to timeout will be -1. for checking the validity of connection i can check the error(Whether error occured or not) but only when the program terminates but unfortunatelly its not teminating.

 

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 3 of 11
(3,296 Views)

Hi,

 

Error 56 indicates connection timeout but your connection is there. Error 66 Indicates Connection lost. So for this you can make a case structure and on error 0 and 56 dont do anything just keep code running rest all error close the connectiona and try to reconnect your network connection.

Thanks and Regards
Himanshu Goyal | LabVIEW Engineer- Power System Automation
Values that steer us ahead: Passion | Innovation | Ambition | Diligence | Teamwork
It Only gets BETTER!!!
0 Kudos
Message 4 of 11
(3,284 Views)

Hi Himashu, 

                            See if the program is still reading the data & if i am connected the error handler after read than untill & unless it wont complete the read operation it wont come here. So can you please tell me implemetation wise what exactly you are suggesting. & this program is in while loop so it will always try to reconnect if everything goes wrong.Smiley Very Happy

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 5 of 11
(3,276 Views)

Hi Ranjeet,

 

Share your developed code so we can have a look and implement the modifications.

Thanks and Regards
Himanshu Goyal | LabVIEW Engineer- Power System Automation
Values that steer us ahead: Passion | Innovation | Ambition | Diligence | Teamwork
It Only gets BETTER!!!
0 Kudos
Message 6 of 11
(3,269 Views)

Hey himanshu,

                                     I cant send you the code but i can send you the snapshot of that. This is just the abstract one. Please ask if u have any doubt. I tried to explain in the snapshot as much i thought it required. I tried to keep the code as simple as i canSmiley Very Happy

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 7 of 11
(3,265 Views)

Hello Ranjeet,

 

Here you can see this example I posted earlier for folder sync. Over TCP/IP. Just try to implement same in your code use send and receive TCP VIs.Smiley Happy

Thanks and Regards
Himanshu Goyal | LabVIEW Engineer- Power System Automation
Values that steer us ahead: Passion | Innovation | Ambition | Diligence | Teamwork
It Only gets BETTER!!!
0 Kudos
Message 8 of 11
(3,260 Views)

I will check that. Hope this is what i was expecting. Will hear soon from my side.Smiley Wink

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 9 of 11
(3,257 Views)

Can you please help me to understand the code & how it gonna help me.Smiley Sad

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 10 of 11
(3,251 Views)