dwa wrote:
Hello people,
i have a question??
I have an application written in c++ and this throw real time data as
udp-pakets all the time (interval 1 min and values in a wrapper like an
own protocol are floats and longs).
Is there any possibility to catch the udp packets - parse the pakets und
show the values in tables in a html-doc in real time???
What technologies are good? ajax? cgi? ive no idea!!!!!
mfg
david
I recently built a PHP daemon. It uses sockets to listen on a given port for UDP packets.
Take in a request, processes, decides what it needs to do based off the request and then takes
action. Once it is done with said action, starts listening again. This process is done a few times
a second. I have it logging connections to a DB and saving other information to a log file in the
file system.
You could easily take something like this and create a daemon that would listen for incoming
connections and from the data it gets build a page and drop that onto the file system.
here is an example of what I do
<?php
define('LISTEN_IP', 'X.X.X.X'); // IP to listin on '0.0.0.0' would listen on all IP's
define('LISTEN_PORT', 8080); // Port number to listen on (8080)
define('PACKET_SIZE', 512); // 512 bytes
if ( $socket = @stream_socket_server('udp://'.LISTEN_IP.':'.LISTEN_PORT, $errno, $errstr,
STREAM_SERVER_BIND) ) {
while ( true ) {
$packet = '';
while ( $buff = stream_socket_recvfrom($socket, PACKET_SIZE, 0, $remote_ip) ) {
$packet .= $buff;
}
// if need be, loop this until you get to the end of your packet/information
while ( !empty($buff) ) {
$buff = stream_socket_recvfrom($socket, PACKET_SIZE, 0, $remote_ip);
}
// work with $buff here to capture all your data.
// Then also figure out when and if you need to exit
}
fclose($socket);
}
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php