Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 30th, 2005, 11:16 PM   #1
Sfpiano
Newbie
 
Join Date: Jan 2005
Posts: 3
Rep Power: 0 Sfpiano is on a distinguished road
Question Sending data from C++ to php

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.
Sfpiano is offline   Reply With Quote
Old Jan 30th, 2005, 11:22 PM   #2
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
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.
__________________

tempest is offline   Reply With Quote
Old Jan 30th, 2005, 11:34 PM   #3
Sfpiano
Newbie
 
Join Date: Jan 2005
Posts: 3
Rep Power: 0 Sfpiano is on a distinguished road
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.
Sfpiano is offline   Reply With Quote
Old Jan 31st, 2005, 2:40 AM   #4
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
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
kurifu is offline   Reply With Quote
Old Jan 31st, 2005, 9:27 AM   #5
Sfpiano
Newbie
 
Join Date: Jan 2005
Posts: 3
Rep Power: 0 Sfpiano is on a distinguished road
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.
Sfpiano is offline   Reply With Quote
Old Jan 31st, 2005, 10:35 AM   #6
Dizzutch
Professional Programmer
 
Dizzutch's Avatar
 
Join Date: Dec 2004
Location: Worcester, MA
Posts: 441
Rep Power: 4 Dizzutch is on a distinguished road
Send a message via ICQ to Dizzutch Send a message via AIM to Dizzutch Send a message via MSN to Dizzutch Send a message via Yahoo to Dizzutch
open a socket, and send the info to the script, be sure to include the correct headers
__________________
naked pictures of you | PFO F@H stats
Dizzutch is offline   Reply With Quote
Old Feb 1st, 2005, 6:03 AM   #7
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
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
tempest is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:28 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC