LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP/IP matters

Solved!
Go to solution

Hi to all

 

I was just wondering if it is necessary to close TCP/IP connection after an error(e.g connection lost) had occured. Is it ok if I just reopen another connection to the same IP and port without closing the existing connection(that connection which the error had occurred)? Will this lead to any conflicts in my program?

 

Another matter is, is it possible to query the IP of an device connected to my computer?

 

Thank you.

0 Kudos
Message 1 of 17
(4,599 Views)

Hi rdttttttt...,

i think you should close the connection, because the "TCP Close Connection" function will also be executed if you connect an error to the error in.

 

I think there is currently no LabVIEW function to query the IP of the connected device? If you write server and client, then you can send the IP to the server after the connection is created.

 

Hope it helps.

Mike

0 Kudos
Message 2 of 17
(4,585 Views)

You should always close references and/or connections. Not doing so is one of the causes of memory leaks.

 

What do you mean by querying the IP of a device. Is this based on a network name, or an ethernet address? If it's by name, the following will do it:

That's one of the computers in our subnet. 

 

 

Message Edited by smercurio_fc on 02-10-2009 09:14 AM
0 Kudos
Message 3 of 17
(4,576 Views)

Thanks for all your answers.

 

I meant finding unknown Ip address of some device connected to comp.

0 Kudos
Message 4 of 17
(4,563 Views)
Yes, but you still haven't explained what this device is, or how you want to search for it. Is it an instrument or a computer? If it's a computer then it will have a name, and assuming it's on the same subnet, then the code I showed you should work. If it's an instrument then you will need to perform a scan or a broadcast. There's really no other way. Search the forum for "broadcast" and you'll find some examples.
0 Kudos
Message 5 of 17
(4,557 Views)

In a nutshell. 

You could pass a command like "netstat" (or similar0 to the sysexec then redirect the output to the code illustrated above.

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 17
(4,544 Views)

Hi

 

the device is a controller card. It is the only device connected to my computer using an ethernet cable. Internally, the card is configured to have an IP address. Is there a way in LAbview to get this IP? With this info, I can then set up TCP/IP connection to the card using the found IP.

I hope there would be a solution. In windows, the moment the Card is on, It detects the connection between the PC and the device. Is there a way to tap onto that to retreive the card's IP?

 

Thank you.

0 Kudos
Message 7 of 17
(4,522 Views)

Hi

 

As Ben said, you can pass windows ipconfig command to sysexec and work with the resulting string to get an ip. The other possibility is to use your computers network id. Then you can use smercurio_fc example and change your static network name to your ip address.

Do you have access to this card via Measurement and Automation Explorer? 

 

Mvh

souske

 

Message Edited by souske on 02-11-2009 10:20 AM
0 Kudos
Message 8 of 17
(4,509 Views)

rdtttttttttttttt wrote:

Thanks for all your answers.

 

I meant finding unknown Ip address of some device connected to comp.


There is no standard way a TCP/IP device (server) would announce its availability on a network. So each device/server employs its own method. This could be an UDP broadcast inquery to which it will listen on a well known port and send back an UDP packet to the requester with information such as its IP address.

 

Or there is a well known service in the network which can receive service registrations and cancelations and stores all registered services internally. Then a client can inquiry at that registrar service for a specific service name and receives the according information to be able to connect to it.

 

There are probably 500 other ways to skin this cat and all have for sure been tried by some device manufacturers.

 

Rolf Kalbermatter 

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 9 of 17
(4,500 Views)

If you have a TCP/IP Listener for a specific port or service than you are able to get the address of the device that connects to your listener. It can be easily done as there is such an output on the listener VI. (can be resolved by the method shown in this thread a bit higher 🙂 )

 

Marton

NI Hungary

0 Kudos
Message 10 of 17
(4,497 Views)