Jump to content

How can i get data from C socket server?


colap

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/272722-how-can-i-get-data-from-c-socket-server/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.