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
Share on other sites

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.

Link to comment
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.