LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP read /write

Solved!
Go to solution

Hi,

please i would like to know if it is possible to read and write data using the same port and ip adresse ( connection Id) from to parallel Loops .

 

i want to open connection to the same Ip adresse and port and at the same time read and write date to my device. 

attached below is my VI. 

 

thank you very much for your help in advance 🙂

 

Download All
0 Kudos
Message 1 of 32
(2,831 Views)

Generally speaking, this is a bad idea.  Nothing like A breaking something B needs.

 

You can mitigate some of this by using a single loop to handle the communications and the other loops can communicate with that loop via a queue (to write) and another queue or notifier to get data back.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 32
(2,803 Views)

Hi @Crossrulz,

thank you for your reply. please what do you exactly mean?. i am knew to labview and have already heard about queues but i have never used them. please do you have a link to a quick explanation ?. thanks in advance

0 Kudos
Message 3 of 32
(2,764 Views)

A server generally handles both, writes and reads. A client is usually the opposite side, so the TCP client.vi and the TCP server.vi wouldn't run on the same PC.

 

As far as I learned, only servers handle multiple connections at once and devices usually only support one socket connection. The VIs in LabVIEW only open socket connections to remote devices, so they act like clients too. The TCP server enabling that runs in the background as part of LabVIEW or VISA.

0 Kudos
Message 4 of 32
(2,753 Views)

Hi MaSta,

thanks for your reply.

what i exactly want to do is: i have two Loops (A and B) in my client VI .i want to send data from Loop A to the server and with loop B send data and at the same time read whats the server sends me as reponse to my request. 

 

 

0 Kudos
Message 5 of 32
(2,745 Views)

What kind of server are we talking about? In general, you can open multiple TCP/IP connections to the same server. There is an example how to do it within LabVIEW under Networking->TCP & UDP/TCP Multiple Connections (examples\Data Communication\Protocols\TCP\TCP Multiple Connections)

0 Kudos
Message 6 of 32
(2,733 Views)

Hi cordm,

thans for your reply. what i want to do is write my two clients in the same VI in two Loops that will run at the same time and send datat to the same server.

0 Kudos
Message 7 of 32
(2,730 Views)

Ok, I see. Misunderstood the goal, because you uploaded a server and a client VI of which for the goal only the client VI would be interesting. I didn't open it, but I suppose that's the one with the two loops.

Ok, so there would be one TCP Open.vi and the handle is then passed to both loops, in one the TCP Read.vi and in the other the TCP Write.vi.

Should work.

 

0 Kudos
Message 8 of 32
(2,725 Views)

Please can you explain what you mean? beacause i think that what i did but it doeas not work+

0 Kudos
Message 9 of 32
(2,723 Views)

You have two TCP Open nodes in your Client VI. The server will only accept one of it. TCP Open should happen before the loop. Right now you are trying to open another connection on every loop iteration but only close the last one.

Either make your server accept multiple connections as in the example or only open one connection in the client and share it with both loops as MaSta said.

0 Kudos
Message 10 of 32
(2,717 Views)