944,216 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 615
  • C++ RSS
Oct 14th, 2009
0

php to c++?

Expand Post »
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
realchamp is offline Offline
22 posts
since Oct 2009
Oct 14th, 2009
0
Re: php to c++?
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.
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005
Oct 14th, 2009
0
Re: php to c++?
Click to Expand / Collapse  Quote originally posted by ShawnCplus ...
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++)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
realchamp is offline Offline
22 posts
since Oct 2009
Oct 14th, 2009
0
Re: php to c++?
Click to Expand / Collapse  Quote originally posted by realchamp ...
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
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005
Oct 14th, 2009
0
Re: php to c++?
Click to Expand / Collapse  Quote originally posted by ShawnCplus ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
realchamp is offline Offline
22 posts
since Oct 2009
Oct 14th, 2009
1
Re: php to c++?
Click to Expand / Collapse  Quote originally posted by realchamp ...
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)
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005
Oct 14th, 2009
0
Re: php to c++?
Click to Expand / Collapse  Quote originally posted by ShawnCplus ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
realchamp is offline Offline
22 posts
since Oct 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Just a plain push_back that blows off something
Next Thread in C++ Forum Timeline: C++ Client Help needed!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC