Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

PHP sending time sensitive, non-critical data to desktop computer

$
0
0

I'd like to send small bits of data from my web server to a desktop computer (Raspberry Pi) configured to listen to this data using Python.

 

This data should be sent in real-time but the information is not critical; the computer either gets it or it doesn't. I don't want my site to hang if it is having any type of connection error, such as if the computer is turned off.

 

 

I'm thinking sending a UDP message might be the best approach, but I'm curious how to configure it for PHP:

 

PsudoDbQuery('insert stuff into table');

...

$desktopIpAddress = 'w.x.y.z';

$portNumber = '4321';

$data = 'f03';

fwrite(fsockopen('udp://'.$desktopIpAddress, $portNumber), $data);
...
echo 'You created a new profile';
 
Would an fwrite using fscockopen be a good approach? Should I do anything differently? Thanks!
 

 


Viewing all articles
Browse latest Browse all 13200

Trending Articles