![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2005
Posts: 3
Rep Power: 0
![]() |
Is there a way to send data from a C++ program to a php script on a server? I'm basically trying to create an update server for this program, and I need a way to see if the program needs to be updated.
|
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
Yea, there is. It's called a file.
If you tell us what you're trying to do exactly, maybe some code.. we can help you out. Otherwise, i don't know how to help you.
__________________
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jan 2005
Posts: 3
Rep Power: 0
![]() |
I need it so that the user clicks an 'update' button in the program, and the program passes the current version to the update server for comparison.
|
|
|
|
|
|
#4 |
|
Expert Programmer
|
Uh... wow.. you need to be more specific as to how you want to pass that data, but there are many ways.. one of the more commonly used methods these days is to send the data in a file and have the receiving program read it (by executing it, or having it check for new file data every so many minutes like a normal service). I would recommend using XML for this.
Additionally use can use SOAP, RPC, XML-RPC, uses a PHP fron-end to receive data via a POST (probably HTTP) and invoke a command line utility and pass in the data through the command line from the PHP script... etc.
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jan 2005
Posts: 3
Rep Power: 0
![]() |
I don't really care how it gets there, I just need a way to pass the version string from my program to the server, so the server can compare the recieved string to the version string on the server.
|
|
|
|
|
|
#6 |
|
Professional Programmer
|
open a socket, and send the info to the script, be sure to include the correct headers
|
|
|
|
|
|
#7 |
|
Programming Guru
![]() |
Yea, dizzutch. Good post. Oh, and did i mention you're wrong?
If you open a socket and send the info via post, guess where the response is going to go? You guessed it! Right back at you. For that to work correctly, the user must have the information in a form and hit submit defeating the whole purpose of getting the information to them. Have the C++ program write the info you want to std::cout and use this code to get it. [php] function getCmdResults($cmd) { $str = " "; $pipe = popen($cmd, "r"); while(!feof($pipe)) $str .= fread($pipe, 1024); pclose($pipe); return substr($str, 1, strlen($str) - 1); } // Example (windows): echo getCmdResults("c:\\path\\to\\your\\exe.exe"); // or linux: echo getCmdResults("/home/username/executable"); [/php]
__________________
Last edited by big_k105; Feb 1st, 2005 at 10:12 AM. Reason: no starting flame wars thanks |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|