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.

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.

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++)

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

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.

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)

commented: Fast replies! +0

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.