colap Posted January 5, 2013 Share Posted January 5, 2013 Hi, There is C socket server that gets data from device. I need to pass the data from socket to php script. How can i do this? Can anyone post some sample code? Is it a correct format? system('/usr/bin/php file.php param1 param2'); Now how can i get the data from this? Or is there any other better way to pass data to php script? Quote Link to comment https://forums.phpfreaks.com/topic/272722-how-can-i-get-data-from-c-socket-server/ Share on other sites More sharing options...
trq Posted January 5, 2013 Share Posted January 5, 2013 ? Quote Link to comment https://forums.phpfreaks.com/topic/272722-how-can-i-get-data-from-c-socket-server/#findComment-1403359 Share on other sites More sharing options...
colap Posted January 5, 2013 Author Share Posted January 5, 2013 ? How can you get the value of parameters in php script? I think, the answer is : print_r($_SERVER['argv']); Quote Link to comment https://forums.phpfreaks.com/topic/272722-how-can-i-get-data-from-c-socket-server/#findComment-1403360 Share on other sites More sharing options...
trq Posted January 5, 2013 Share Posted January 5, 2013 My point exactly. The code example you posted and the topic of your question seem unrelated. Do you want to pass data to a php cli application? Ask that fucking question! What that has to do with some server written in C is beyond me. Quote Link to comment https://forums.phpfreaks.com/topic/272722-how-can-i-get-data-from-c-socket-server/#findComment-1403363 Share on other sites More sharing options...
gizmola Posted January 5, 2013 Share Posted January 5, 2013 Do you want to pass data to a php cli application? Ask that fucking question! What that has to do with some server written in C is beyond me. That is some funny shit Tony. Quote Link to comment https://forums.phpfreaks.com/topic/272722-how-can-i-get-data-from-c-socket-server/#findComment-1403367 Share on other sites More sharing options...
trq Posted January 5, 2013 Share Posted January 5, 2013 That is some funny shit Tony. Im pretty over cryptic posts. Quote Link to comment https://forums.phpfreaks.com/topic/272722-how-can-i-get-data-from-c-socket-server/#findComment-1403368 Share on other sites More sharing options...
salathe Posted January 5, 2013 Share Posted January 5, 2013 Is it a correct format? system('/usr/bin/php file.php param1 param2'); Did you try it? What happened? Now how can i get the data from this? In the PHP script, look at the $argv array. Or is there any other better way to pass data to php script? Of course there are other ways. To give one example, you could use popen() and push the data to the PHP script via stdin. This would also allow you to get feedback out of the PHP script (more than just its exit code) by reading its stdout/stderr. But for simplicity, system() will serve you well enough. P.S. Tony, the OP has some C code and wants to call a PHP script from it. Maybe the confusion arose from asking a C question on a PHP forum? Upon reading it as a C question, the original post isn't particularly cryptic at all. Quote Link to comment https://forums.phpfreaks.com/topic/272722-how-can-i-get-data-from-c-socket-server/#findComment-1403414 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.