03-23-2009 03:54 AM
Hello,
I have a VI how should received Datas from another PC, using a TCP/IP connection,
My VI could establish the connection, receive the data's, but if i loose the connection im not able to reconnect, because i dont know how to test if my pc is connected to the other one,
Thank you for your help,
Best Regards,
Solved! Go to Solution.
03-23-2009 04:28 AM - edited 03-23-2009 04:29 AM
HI,
For better understanding can you upload your VI.
You can also find the inbuild example, \examples\comm\TCP.llb and Data Server.vi, Data Client.vi.
Hope this helps
03-23-2009 05:05 AM - edited 03-23-2009 05:05 AM
Hi Salim,
You can just try to establish a connection and check the error (if there is one).
If you want to check whether you're connected to a network you can for instance check the PCs IP address (only when using DHCP), see attached image.
Hope this helps,
Daniel
03-23-2009 06:15 AM
Hai,
if the connection with the PC is lost an error is thrown (error number: 56, 60 i remember just check it out) when you try to read or write to that system. On detecting the error you can close the TCP connection and re-open the connection with the PCand re-transmit the data which you where not able to send in the previous attempt.
Hope this helps.
03-23-2009 07:22 AM
03-23-2009 02:12 PM - edited 03-23-2009 02:14 PM
salim_mjs wrote:Hey,
I was checking for error 66, i think it check if the connection have been closed so i reconnect
do you think that error 56, or 60 are better?
with regards,
56 is timeout. It will depend on your remote service if that should be treated as error or ignored. If it is a server application it should certainly be able to react within the timeout. But if your host applcation is the server and the remote application is the client it would be very common to receive a timeout error when polling the client if he has new data to send.
Checkout the previously mentioned examples they really give you a good idea about how network communication over TCP/Ip should about work, eventhough there is still a lot to be improved to create a really reliable connection. But start from there and then come back if you get trouble.
Rolf Kalbermatter
06-27-2024 05:50 AM
Hi @ rolfk
sorry to comment on such an old thread, but I can't find the solution I need, and I've seen your comments on similar related topics, internet connection!
I have a LV program, which has several SubVIs and they are all sending SQL queries for different functions. When I disconnect my laptop from the internet (cable), my laptop re-establishes internet within a few seconds and connect to wifi, but my program doesn't. I have found out that I can check with TCP if the connection is still there, but i don't know how to use this information, in case it is negative, how to reconnect to wifi or next available internet? can you help me with that please? I've attached the check for internet snippet part.
06-27-2024 09:30 AM
This seems to belong to this discussion.
You don't need to check for generic internet connectivity. All you need to do is just try to reconnect to your SQL every second or so, until it succeeds. (Or a time is reached where it should give up).