I am trying to monitor the status of an agent from the web. The agent opens a UDP socket and consistently send messages reflecting its status on a non-regular basis. I have a script,listen.pl, that opens a socket,binds it to the web-server IP and listen for incoming messages.
What I have in mind is to dynamically update a web page everytime a new message comes in.I've tried the following:
1)open a filehandle on listen.pl and use a while loop to print each line to html. I realize the web page wouldn't show until the while loop terminates,i.e. it cant refreshes line by line while each line of meassage comes in.
2)I modify listen.pl to take in one message and then close the socket. Doing this, the message appears. However ,it's not what I wanted. Next, I put everything in a subroutine and call the subroutine twice.By right, the first call would have generated the first message and then followed by the second.However, all I get is a long wait and the 2 messages pop out at the same time. I tried both including and excluding the html starting/ending tags in the subroutine.
Does anyone have any suggestion how to do this properly? Also,I need a way of letting the cgi script knows when the browser window is closed so that it will stop running listen.pl.Thanks
In reply to Dynamic Updating of a HTML page by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |