From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
11-22-2012 02:34 PM
Hi,
I'm building a labview server that communicates with a java client.
The communication works but I have 2 problems:
- Labview writes only string via tcp, so I cast Double to String, but when I try to read it reads a wrong value. Someone knows what kind of stream I can use in java?
- How can I obtain a multithreading server? After the first read I need to wait for other events, that will arrive during the execution of the program.
I tried with two while loop with 2 tcp listener on different ports, but it didn't work.
Thanks for your help,
Veronica
Solved! Go to Solution.
11-22-2012 02:41 PM - edited 11-22-2012 02:44 PM
@Skeggy88 wrote:
Hi,
I'm building a labview server that communicates with a java client.
The communication works but I have 2 problems:
- Labview writes only string via tcp, so I cast Double to String, but when I try to read it reads a wrong value. Someone knows what kind of stream I can use in java?
- How can I obtain a multithreading server? After the first read I need to wait for other events, that will arrive during the execution of the program.
I tried with two while loop with 2 tcp listener on different ports, but it didn't work.Thanks for your help,
Veronica
Hi Veronica,
It could be the byte order that messes it up for you?
Try to flip the order before you send it and see if it works?
A few LabVIEW/Java links:
http://lavag.org/topic/2723-tcpip-java-labview/
http://forums.ni.com/t5/LabVIEW/problem-with-tcp-server-sending-data-to-java/td-p/1102302
An example object oriented threading example:
https://decibel.ni.com/content/docs/DOC-24498
What you can do there is spawn/create a new thread with each incoming connection.
Br,
/Roger
11-22-2012 03:03 PM
I had already seen these examples on java. Tomorrow I will try to reverse data, because here in Italy it's late.
Then, I don't understand this multithreading VI... I thought that I have to do something simpler.
I attach my idea. Is it totally wrong?
11-22-2012 03:13 PM
@Skeggy88 wrote:
I had already seen these examples on java. Tomorrow I will try to reverse data, because here in Italy it's late.
Then, I don't understand this multithreading VI... I thought that I have to do something simpler.
I attach my idea. Is it totally wrong?
I think you are using a Apache Tomcat/proxy port?
Perhaps you should move to ports in the range:
http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
It's common to have an inner tcp read loop, and to go back listening when your tcp session ends.
http://www.ni.com/white-paper/3982/en
http://www.ni.com/white-paper/2710/en
Br,
/Roger
11-23-2012 06:01 AM
I read these examples, but connections are put in a queue and I need to manage 2 connection in the same moment.
I attach a little "summary" of my program.
I need to:
- Read the command "ON0", create a file and acquire data using a DAQ. These data are written on file and also via tcp, so the connection must be active.
- Wait for events. Events will activate the case structure that writes event on file.
Can someone explain me clearly what I need to do?
I'm a beginner with labview but I have to finish this program this week because I must send my thesis to my professor.
Thank you and sorry for my english.
11-23-2012 03:35 PM
Is there anyone?
11-23-2012 10:12 PM
If you want N clients to each communicate with a dedicated instance of your server, then you must the set the server VI to be "re-entrant". Then, when a client connection is accepted, you spawn a new server instance and pass it the connection reference.
11-24-2012 08:39 AM
What's the meaning of "re-entrant"??
11-24-2012 01:29 PM
Re-entrancy means the VI can be "cloned" aka "spawned", that is, multiple copies of the VI can be in memory at the same time. You can set this property under "File...Properties...Execution (Reentrancy). Since you want each server instance to have its own data (not shared), use the "Preallocated clone" option.
The way I did this was to have a listener VI that dynamically calls the server VI when a connection is accepted. The listener VI passed the connection reference to the new server instance.
11-25-2012 09:29 AM
Hi,
thanks for your reply.
I try to follow your advice and I did the "complete program" re-entrant.
I attach the server, but the tcp listener stops the execution.
What's wrong? I don't know what to do