How to generate an event?

Dear all,

I’m doing some tests and I want to asynchronously call a web server and generate an event when a certain type of data is received.
In essence, I want to, ideally, be able to maintain an open connection to a web server and wait for it to push information back to me. When it does, I want to generate an event that my code can pick up and act on.
Worst case scenario, I want to be able to make this asynchronous call every X seconds and act on it.

For now, I have done this in an EventLoop function:
while true
msg = wait(0, m.port)
xfer.SetURL("http://192.168.1.52/roku/getdata.php)
num_value = strtoi(xfer.gettostring())

But this OBVIOUSLY doesn’t scale as my web server is getting hit several times per second.

Any ideas on how I do this in a scalable way?

Thank you,
Luis

Here’s an example: http://forums.roku.com/viewtopic.php?f=34&t=47659&start=30#p327128

Thank you Trevor, I’m going to take a look at that! :o))