LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to allow multiple apps to read from same udp port?

Solved!
Go to solution

hello all!

when i'm trying to open the same udp socket from two different applications, i get error 60 :

"Address in use".

i know for sure that it is possible.

but how i do that with labview ?

thanks.

guy.

0 Kudos
Message 1 of 10
(8,163 Views)

Well, I think you have answered your own question. You will need to setup a framework where you initialize just once and then pass that reference to both applications that use the read and write VIs to access the UDP port.

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 2 of 10
(8,159 Views)

ok , i will explain more clearly.

i have one application that's not created in labview, and i have no control on it , but i know for sure i can use the same port this app is using for listening

because it has been done with some other app (also not created in labview).

so, this app runs first and listen to a port.

now i want that my app (which i created in labview) will use the same port - also for listening.

how can i tell labview to open the same port without having to encounter error 60 ?

0 Kudos
Message 3 of 10
(8,153 Views)

I agree with Adnan that this is not really possible with the normal mechanisms. The OS needs to know which application should get the data. An exception are e.g. packet sniffers (such as Wireshark) that intercept the network traffic at a lower level and passively listen in.

 

Please provide some details on what "other applications" have done this.

0 Kudos
Message 4 of 10
(8,145 Views)

those applications are costume made by software engineers at my workplace, written in C#.

you cannot find them at the internet.

i understand that what i'm asking to do (passive listening to a port) can't be done with the current labview version, is that right ?

0 Kudos
Message 5 of 10
(8,141 Views)

Yes, it can be done, but you need to dig a little deeper (e.g. using activeX or a third party dll).

 

You might want to get started by reading this thread.

0 Kudos
Message 6 of 10
(8,137 Views)

@hookso wrote:

those applications are costume made by software engineers at my workplace, written in C#.

you cannot find them at the internet.


I beg to differ. There are numerous examples of how to write a sniffer in C#. Here's one example: http://www.codeproject.com/KB/IP/CSNetworkSniffer.aspx. The software engineers at your company would have done something very similar. So, you could use .NET to create a sniffer or you could try the WinPCAP alternative that altenbach mentioned.

0 Kudos
Message 7 of 10
(8,132 Views)
Solution
Accepted by topic author hookso
I have mannaged to solve the problem.I wrote a program in c#, and used the udpclient class. I enabled socket option called reuseAddress.
than imported the dll to labview.
I was able at last to open udp port that was taken by another application. Note that this could be done only if the transmitting was a broadcast, but this is enough for me.
0 Kudos
Message 8 of 10
(8,052 Views)

Could u share the the labview code, c# and required dll.

 

0 Kudos
Message 9 of 10
(6,849 Views)

Hey Hookso,

 

It's been a while since this thread was used, but I have a similar use-case. Do you think you could share the C# code snippet where you configure the socket? I'm sure I could find something on stackoverflow, so I'll probably go there if no response, but I figured maybe we could just blow the dust off of this thread.

0 Kudos
Message 10 of 10
(6,250 Views)