LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get TCP Service Name Port Number

Solved!
Go to solution

The TCP Listen and TCP Create Listener VIs have an input terminal named 'Service Name', once a listener is created in the LabVIEW application is it possible to query which named service is running and on what port in an external application? The external application may or may not be developed in LabVIEW.

 

The TCP Create Listener VI outputs the port number used, this is useful for information purposes but I can see no automatic method for an external application to get this information?

 

The C++ function getservbyname does not return any information given the known, created and listening LabVIEW TCP listener.

0 Kudos
Message 1 of 5
(3,683 Views)
Solution
Accepted by topic author tcsilixa

From the LabVIEW help:

 

service name creates a known reference for the port number. If you specify a service name, LabVIEW registers the service name and the port number with the NI Service Locator.

 

 

NI Service Locator:

 

http://digital.ni.com/public.nsf/allkb/227453F884CE035386256E55007A303D


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

Message 2 of 5
(3,671 Views)

Perfect. Thanks.

0 Kudos
Message 3 of 5
(3,664 Views)

So all the stuff I've seen on the internet and in the forums assumes that you are trying to PUBLISH a LabVIEW service; therefore they talk about the LabVIEW Service Locater. But what if you are trying to find the port number for a NON-LabVIEW service that is NOT aware of the LabVIEW Service Locater, but uses /etc/services (Linux/UNIX) or \etc\services (Windows) instead?

 

I have a LabVIEW program that wants to connect via TCP to a service written by someone else, and it is NOT a LabVEW service. It's port number is specified in \etc\services - it's a 'known' service in our local environment. BUT... I do not want to hard code the port number, because depending on what else is installed that port number can change. Which is the whole POINT of the services file.

 

So how can I do a 'getservbyname()' call using LabVIEW? I can of course parse the \etc\services file myself; but there has to be an already existing and accepted way to do this, I just haven't found it yet. Any help?

 

By the way, this also applies to gethostbyname() and the hosts file...

0 Kudos
Message 4 of 5
(2,625 Views)

getservbyname() and gethostbyname() are system API functions. You can call them from LabVIEW too, by using the Call Library Node. Under Windows they are located in wsock32.dll while under Linux they are located in libc.so.6.

Rolf Kalbermatter
My Blog
Message 5 of 5
(2,618 Views)