LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I assign the same port number to two different UDP connections?

Hi,

 

In my setup, the computer where the LV app will be running has two network cards, with two different IP addresses. On the test hardware outside the computer, I have a device (also with two different IP addresses) that will send 2 messages to the two different IP addresses (but to the same port number). 

 

Is there a way I can open two UDP read sessions (one for the IP1 and one for IP2) that needs to listen to the same assigned port number?

 

It's a little confusing, but bascially:

 

Device                               Computer                                  

192.168.1.1 --------->   192.168.1.2 Port 1000

192.168.0.1 --------->   192.168.0.2 Port 1000

Note: the "Device" will send out  both messages continously.

 

Right now, what I did was:

1) Open the 1.1 to 1.2 session, received the UDP message from 192.168.1.1.

2) Closed the UDP read session of 1.1 to 1.2.

3) Open the 0.1 to 0.2 session, BUT received the UDP message from 192.168.1.1 rather then 192.168.0.2.

 

Does the app bind the port to one UDP instance/Network address?

 

 thanks,

0 Kudos
Message 1 of 3
(4,069 Views)

I don't believe that there is any network address binding.  The UDP Open VI determines which network card you are using and the UDP read function determines which IP address you pull the data from.  Since you are specifying all of the parameters, it should not carry over after you close a session.  There may be a wait required for the connections to reset.  Are you doing this programmatically, or are you stopping and restarting your VI?  Can you send a screen shot of both of your UDP connections on your block diagram? 

 

 

Nick Keel 

Applications Engineering 

National Instruments

Nick Keel
Product Manager - NI VeriStand and Model Interface Toolkit
National Instruments
0 Kudos
Message 2 of 3
(4,047 Views)

I tried to add a time wait between open and closing of the two UDP sessions.

But becuase there's a timing requirement on my end, I have to open the second UDP session within 0.5 seconds after closing the first one.

 

I went back and  check the code and I see that before I use the second session to read the UDP port, I opened a UDP connection with the same port, send it out to the device, then closed the connection. Let me try to not specify a port on the first UDP connection and see if that resolves my issue. 

 

thanks,

 

chi P.

0 Kudos
Message 3 of 3
(4,042 Views)