php to c++?

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2009
Posts: 6
Reputation: realchamp is an unknown quantity at this point 
Solved Threads: 0
realchamp realchamp is offline Offline
Newbie Poster

php to c++?

 
0
  #1
Oct 14th, 2009
Hello!

I was wondering if it were possible for me to have a PHP script which would send a line of charactors to my C++ program. The C++ program needs to run all the time to recieve the inputs from PHP. Both the C++ program and my webserver is on the same machine(localhost).

So -> I was thinking on sending a socket to my C++ program and then do a "if" statement to check if it knew the socket, checking agianst predefined stuff and if it regonizes something, it would do a block for that match.


- realchamp.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,402
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey
 
0
  #2
Oct 14th, 2009
There are a couple of ways to do it that pretty easy. If you're using the socket approach you can just have PHP open a client socket and send data to the C++ app. The other way is just to have C++ poll a file that PHP writes to. The latter is quite expensive but easier to implement.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 6
Reputation: realchamp is an unknown quantity at this point 
Solved Threads: 0
realchamp realchamp is offline Offline
Newbie Poster
 
0
  #3
Oct 14th, 2009
Originally Posted by ShawnCplus View Post
There are a couple of ways to do it that pretty easy. If you're using the socket approach you can just have PHP open a client socket and send data to the C++ app. The other way is just to have C++ poll a file that PHP writes to. The latter is quite expensive but easier to implement.
Hmm the first one sounds like something I'd like to have, do you have any tutorials for that? (Both PHP and C++)
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,402
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey
 
0
  #4
Oct 14th, 2009
Originally Posted by realchamp View Post
Hmm the first one sounds like something I'd like to have, do you have any tutorials for that? (Both PHP and C++)
http://php.net/sockets

For C++ you might want to look around for forums, there's bound to be a link to a good one. If not, just google C++ sockets there is a veritable shit-ton
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 6
Reputation: realchamp is an unknown quantity at this point 
Solved Threads: 0
realchamp realchamp is offline Offline
Newbie Poster
 
0
  #5
Oct 14th, 2009
Originally Posted by ShawnCplus View Post
http://php.net/sockets

For C++ you might want to look around for forums, there's bound to be a link to a good one. If not, just google C++ sockets there is a veritable shit-ton
Alright thanks for the quick answer!

And does the PHP need to run the socket server or are the C++ app supposed to do that?

Both should be able to send back and forward. The C++ program just needs to send basic status reports.
Last edited by realchamp; Oct 14th, 2009 at 7:51 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,402
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey
 
1
  #6
Oct 14th, 2009
Originally Posted by realchamp View Post
Alright thanks for the quick answer!

And does the PHP need to run the socket server or are the C++ app supposed to do that?
Based on what you needed it would make sense for the C++ app to listen (be the server) and PHP to send the data to the server (client)
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 6
Reputation: realchamp is an unknown quantity at this point 
Solved Threads: 0
realchamp realchamp is offline Offline
Newbie Poster
 
0
  #7
Oct 14th, 2009
Originally Posted by ShawnCplus View Post
Based on what you needed it would make sense for the C++ app to listen (be the server) and PHP to send the data to the server (client)
Okay. Thanks so much!

-- realchamp.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC