Re: [PHP] c++ and php! search for a brigde
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 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
Re: [PHP] c++ and php! search for a brigde
On 8/28/07, Gevorg Harutyunyan <[EMAIL PROTECTED]> wrote: > > Barev David, > > I think this is solution > > 1. C/C++ updates database (MySQL or other) > 2. There is some PHP file that is viewing your DB info(printing static > info) > 3. There is other PHP file that is using AJAX for interactive update of > information (This one is sending request to first PHP file and if needed > updating second one) > > I don't know maybe this is very complex, but I would choose this one ;) > > Best, > Gevorg > > -Original Message- > From: David Giragosian [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 28, 2007 10:08 PM > To: Simon > Cc: php-general@lists.php.net > Subject: Re: [PHP] c++ and php! search for a brigde > > On 8/28/07, Simon <[EMAIL PROTECTED]> wrote: > > > > you can use sockets in php, they work the same as berkley sockets > > you can use system() in php, to call your C++ program (the program > > could output html) > > in my opinon CGI with C/C++ is obsolete, use php/apache for best > results! > > > > another nice way is to have your C++ program independent, outputs its > > results/values into a database (mysql)... and a php page will just > > read what's in the database to display it nicely. > > > That's what we do here. C/C++ app gathers and inserts the data into the > db, > minute by minute, and PHP apps are used for display, reports, graphics, > etc... Our LAMP system has had nary a glitch in over 3 years of continuous > usage. > > That would be a clean way of doing it. > > > > Good luck! > > > > David > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > No, this is not that tough. we did it before. 1. A C program retrieves data from several (more than 100) servers. 2. It saves the data in the MySQL db. 3. A php page is loaded with an ajax enabled 4. then a ajax call is sent to the same php file. it uses the setTimeout function. 5. Data comes in json format. 6. data is formated by javascript and shown in the page. Thats it. -- shout at http://shiplu.awardspace.com/ Available for Hire/Contract/Full Time
RE: [PHP] c++ and php! search for a brigde
Barev David, I think this is solution 1. C/C++ updates database (MySQL or other) 2. There is some PHP file that is viewing your DB info(printing static info) 3. There is other PHP file that is using AJAX for interactive update of information (This one is sending request to first PHP file and if needed updating second one) I don't know maybe this is very complex, but I would choose this one ;) Best, Gevorg -Original Message- From: David Giragosian [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 28, 2007 10:08 PM To: Simon Cc: php-general@lists.php.net Subject: Re: [PHP] c++ and php! search for a brigde On 8/28/07, Simon <[EMAIL PROTECTED]> wrote: > > you can use sockets in php, they work the same as berkley sockets > you can use system() in php, to call your C++ program (the program > could output html) > in my opinon CGI with C/C++ is obsolete, use php/apache for best results! > > another nice way is to have your C++ program independent, outputs its > results/values into a database (mysql)... and a php page will just > read what's in the database to display it nicely. That's what we do here. C/C++ app gathers and inserts the data into the db, minute by minute, and PHP apps are used for display, reports, graphics, etc... Our LAMP system has had nary a glitch in over 3 years of continuous usage. That would be a clean way of doing it. > > Good luck! David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] c++ and php! search for a brigde
On 8/28/07, Simon <[EMAIL PROTECTED]> wrote: > > you can use sockets in php, they work the same as berkley sockets > you can use system() in php, to call your C++ program (the program > could output html) > in my opinon CGI with C/C++ is obsolete, use php/apache for best results! > > another nice way is to have your C++ program independent, outputs its > results/values into a database (mysql)... and a php page will just > read what's in the database to display it nicely. That's what we do here. C/C++ app gathers and inserts the data into the db, minute by minute, and PHP apps are used for display, reports, graphics, etc... Our LAMP system has had nary a glitch in over 3 years of continuous usage. That would be a clean way of doing it. > > Good luck! David
Re: [PHP] c++ and php! search for a brigde
you can use sockets in php, they work the same as berkley sockets you can use system() in php, to call your C++ program (the program could output html) in my opinon CGI with C/C++ is obsolete, use php/apache for best results! another nice way is to have your C++ program independent, outputs its results/values into a database (mysql)... and a php page will just read what's in the database to display it nicely. That would be a clean way of doing it. Good luck! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] c++ and php! search for a brigde
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php