LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP/UDP Read/Write thread safety

My main question is fairly straight forward: do the TCP and/or UDP write (and/or read) VIs have any thread safety and, if so, what?

 

I'm mainly focused on writing (for now) but it is likely I'll be writing to TCP and UDP sockets (one of each) in multiple locations and hence (most likely) multiple threads.  I would like to know if I need to be concerned by this and implement something to make them thread safety (e.g. wrapping the VIs in non-reentrant ones)?

 

Note, I'm implementing an interface, so I can't do anything like creating new sockets on new ports; the ones I have and what I do with them are fixed.  I just need to manage accessing them in multiple threads.  I can think of ways of doing this, so all I'm asking is if this is already handled and, if so, how.

 

I'm using a Real-Time Target if that makes a difference...

 

Many thanks,

0 Kudos
Message 1 of 2
(2,740 Views)

The problem exists if you are writing / reading to the exact same socket. In that instance, the ability to perform an atomic operation (eg. write a request out and read back a response) is fundamental and the Read / Write nodes are separate - so there is room of threading-related issues. Therefore you need to manage the atomic operation yourself. A non-reentrant VI is one way to do it and there are of course many other constructs in LV that will do something similar, each with their own pros/cons.

 

 

The only real issue you might encounter with a non-reentrant VI is if your requirements change and now you need to have more than one socket going at the same time in which case the non-reentrancy will inhibit parallel operations on each socket.

Message 2 of 2
(2,690 Views)