取消
顯示結果 
搜尋替代 
您的意思是: 

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 積分
1 條訊息(共 11 條)
5,789 檢視

@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 積分
2 條訊息(共 11 條)
5,761 檢視

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 積分
3 條訊息(共 11 條)
5,750 檢視

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 積分
4 條訊息(共 11 條)
5,738 檢視

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.極度高興的表情

--------------------------------------------------------------------------------------------------------
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 積分
5 條訊息(共 11 條)
5,730 檢視

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 積分
6 條訊息(共 11 條)
5,723 檢視

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 can極度高興的表情

--------------------------------------------------------------------------------------------------------
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 積分
7 條訊息(共 11 條)
5,719 檢視

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.高興表情

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 積分
8 條訊息(共 11 條)
5,714 檢視

I will check that. Hope this is what i was expecting. Will hear soon from my side.眨眼表情

--------------------------------------------------------------------------------------------------------
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 積分
9 條訊息(共 11 條)
5,711 檢視

Can you please help me to understand the code & how it gonna help me.難過表情

--------------------------------------------------------------------------------------------------------
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 積分
10 條訊息(共 11 條)
5,705 檢視