LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Virtual/pseudo TCP server to locally (non-network) simulate TCP/IP communication

Hi all,

I have a VI that opens a TCP connection with a server and talks to it. This is in "production" mode.

 

However, when I'm on a development PC, I don't have access to the actual server to establish a TCP connection and talk to it. But I need a "pseudo" server on my development PC that behaves exactly like the real server (i.e. has the same IP address, and can talk to my VI through a TCP connection).

 

I looked at the standard LabVIEW example of TCP server. It doesn't help me at all. The TCP Listener functions don't really make sense. Does anyone have any ideas to make a "pseudo" server?

0 Kudos
Message 1 of 6
(3,332 Views)

So you need to create a LabVIEW application (stand-alone or another VI) with a TCP Server that can run on your local machine via localhost (127.0.0.1) and your VI then connects to the local IP 127.0.0.1 to perform whatever data communications you need (your VI would have a setting or similar to switch to using the local IP instead of whatever your "production" IP is). This is a fairly standard way of solving your issue to debug/test your VI without using the production environment.

 

What parts of the TCP Server example are you struggling with? So that we can give you more directed advice.

0 Kudos
Message 2 of 6
(3,316 Views)

So I want to keep my VI unchanged (i.e. use the "production" IP). Is that not possible at all? Because then I'd have to remember to change back to production IP when I want to implement any code changes.

 

 

0 Kudos
Message 3 of 6
(3,312 Views)

Have you considered a simple solution such as adding a control such as "Simulate" to your VI and, if its true, using the localhost IP rather than your production one (Select node)? That way any logic changes to the VI have no impact on the IP choice.

0 Kudos
Message 4 of 6
(3,307 Views)

The IP address of a server is defined by the IP address of the computer it is running on, not by the IP address your client wants to connect to. It's about the same with ZIP codes. If someone wants to send you a mail he has to know YOUR ZIP code and use it rather than a ZIP code that pleases him. And if he wants to send a mail to someone else he can't simply write your ZIP code on the envelop because that is the only one he can write, but he has to put the ZIP code on the envelop of whomever he wants to send the letter to.

 

Of course he can ask the other person to move into your house so he can send the letter to him using your ZIP code, but I'm not sure you would agree with that Smiley Very Happy

Rolf Kalbermatter
My Blog
Message 5 of 6
(3,296 Views)

@abvenk ha scritto:

So I want to keep my VI unchanged (i.e. use the "production" IP). Is that not possible at all? Because then I'd have to remember to change back to production IP when I want to implement any code changes.


A possibility is to load the server IP as a string from an ini file (see the Config File VIs palette).

If you define the production server address as the default one, you will be able to redefine the IP on any other test system (not necessarily your own development PC) with no behaviour change in the production environment.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 6 of 6
(3,260 Views)