Jump to content

Is there an event for TCP/IP listening


Recommended Posts

I am trying to finish a VI which can listen to a TCP/IP connection and also be able to respond to user action at the same time. I put them in one while loop and keep checking each instance, like anything from TCP/IP and does user do anything on the front panel.

But the result is the VI is not working at all. When it goes to listen TCP/IP, it stops and waits for data. I wonder if there is an event-driven listening for TCP/IP so that the VI doesn't need to stuck there for incoming data. Or other structure to implement what I want: both monitoring the TCP/IP and responding to user action?

Thanks.

Link to comment

QUOTE (menghuihantang @ Jun 17 2008, 12:55 PM)

I am trying to finish a VI which can listen to a TCP/IP connection and also be able to respond to user action at the same time. I put them in one while loop and keep checking each instance, like anything from TCP/IP and does user do anything on the front panel.

But the result is the VI is not working at all. When it goes to listen TCP/IP, it stops and waits for data. I wonder if there is an event-driven listening for TCP/IP so that the VI doesn't need to stuck there for incoming data. Or other structure to implement what I want: both monitoring the TCP/IP and responding to user action?

Thanks.

Use parallel while loops. That's what LabVIEW is great at. Keep each loop as simple as possible and minimize the interaction with the other loop. If you need to share data or events, you are going to need to use some kind of communication system outside of the dataflow, like local or global variables, queues, notifiers, functional globals, datasockets.

Your best bet is probably to have one loop for TCP/IP listening, one for user event listening, and then a third loop where all the action takes place, fed by your own events generated in the other loops and then passed into the main execution loop. Queues are the favorite way to do this. Do a search on "producer-consumer architecture" on this site and at zone.ni.com.

Link to comment

QUOTE (menghuihantang @ Jun 17 2008, 03:55 PM)

I am trying to finish a VI which can listen to a TCP/IP connection and also be able to respond to user action at the same time. I put them in one while loop and keep checking each instance, like anything from TCP/IP and does user do anything on the front panel.

But the result is the VI is not working at all. When it goes to listen TCP/IP, it stops and waits for data. I wonder if there is an event-driven listening for TCP/IP so that the VI doesn't need to stuck there for incoming data. Or other structure to implement what I want: both monitoring the TCP/IP and responding to user action?

Thanks.

Jason's solution is the best of course. Another more quick and dirty solution is to use the timeout input to the Listen VI. Set it to a value that is not to slow for user interaction (250ms is usually quite small enough). Of course the listen node then wil return if there has a connection arrived AND also if the timeout has expired and in the second case accordingly return a timeout error which you have to filter and ignore and go back to listening again.

But as mentioned, Jason's solution is the more robust one and definitly has my preference by far.

Rolf Kalbermatter

Link to comment

QUOTE (rolfk @ Jun 18 2008, 03:56 AM)

Jason's solution is the best of course. Another more quick and dirty solution is to use the timeout input to the Listen VI. Set it to a value that is not to slow for user interaction (250ms is usually quite small enough). Of course the listen node then wil return if there has a connection arrived AND also if the timeout has expired and in the second case accordingly return a timeout error which you have to filter and ignore and go back to listening again.

But as mentioned, Jason's solution is the more robust one and definitly has my preference by far.

Rolf Kalbermatter

Thanks, guys. Jason's solution led me to dig in another big topic. I found out that LabVIEW actually has all structure templates ready for use (yeah, I just found out today). Cool.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.