13 Replies - 3057 Views - Last Post: 07 July 2007 - 02:41 PM Rate Topic: -----

#1 saritha  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-February 07

PASS DATA FROM PHP TO C

Posted 14 February 2007 - 11:47 PM

How do I pass data from PHP as input to a C function
Is This A Good Question/Topic? 0
  • +

Replies To: PASS DATA FROM PHP TO C

#2 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: PASS DATA FROM PHP TO C

Posted 15 February 2007 - 08:47 AM

Well it depends on the enviroment you're working with and what you're trying to accomplish.

Also, you will need to show us your work thus far.
Was This Post Helpful? 0
  • +
  • -

#3 haveacigar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 03-February 07

Re: PASS DATA FROM PHP TO C

Posted 15 February 2007 - 11:05 AM

As in write onto the server ?
Was This Post Helpful? 0
  • +
  • -

#4 Craige  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 02-November 06

Re: PASS DATA FROM PHP TO C

Posted 21 February 2007 - 08:31 PM

We need more details. You could do it a number of ways. You could write the C script as a cgi program. You could write a c function as a PHP addon for your server.

We need to know more about your situation.
Was This Post Helpful? 0
  • +
  • -

#5 jrb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 01-July 07

Re: PASS DATA FROM PHP TO C

Posted 01 July 2007 - 03:31 PM

OK, I was interrested in this task but saw that it ended abruptly.

Say I have a cms server and a client browsing the cms would want to send data from a mysql db to a client running a 'c' application somewhere out there in my network. Say the data was just a single character or more generally a byte of data. How would I acomplish this?

thanks jrb
Was This Post Helpful? 0
  • +
  • -

#6 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: PASS DATA FROM PHP TO C

Posted 02 July 2007 - 02:57 PM

You're being just as helpful as saritha was.

You could write a socket based solution, write and then read a file on a server somewhere, write a more advanced socket based thing that adhears to http. There are a million and one ways to accomplish this task and you're only limited by your imagination and willpower.
Was This Post Helpful? 0
  • +
  • -

#7 jrb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 01-July 07

Re: PASS DATA FROM PHP TO C

Posted 04 July 2007 - 10:40 AM

:^:

View Posthotsnoj, on 2 Jul, 2007 - 02:57 PM, said:

You're being just as helpful as saritha was.

You could write a socket based solution, write and then read a file on a server somewhere, write a more advanced socket based thing that adhears to http. There are a million and one ways to accomplish this task and you're only limited by your imagination and willpower.


Wait a minute here hotsnoj,

First of all I realize there must be numerous ways to acomplish the task. I am reasonably certain though that there are not a million and one ways unless you are talking about a million and one ways to use the information transfer itself.

Secondly I posted the question because after searching the web I did not find one of the million and one ways you seem to be aware of to simply port a byte of data from php to c without polling.

Thirdly and most importantly, I missed something here. I was asking someone in the forum for advice and not an arrogant snide remark from someone who appears to be asking me for help.

So what kind of help do you need to answer the question? Do you want me to walk your dog?
Do you need my C++ code, my PHP5 code, my MYSQL DB structure my operating system my hardware platform the type of coffee I drink or maybe from what I have seen you are not capable of answering a concrete question. Sorry I must be on the wrong planet here...
Was This Post Helpful? 0
  • +
  • -

#8 jrb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 01-July 07

Re: PASS DATA FROM PHP TO C

Posted 04 July 2007 - 11:07 AM

By the way, of the total of 68 snippets there is nothing even close to porting data. If I can figure out how to get my task solved I will most definitely share it with the forum and maybe someone like me or saritha may receive help in the future without a wishy washy bluff statement from with absolutely no substance.
Was This Post Helpful? 0
  • +
  • -

#9 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: PASS DATA FROM PHP TO C

Posted 04 July 2007 - 01:05 PM

jrb, you're really trying my patience. I answer to the degree of the question. If you provide no code and are fuzzy on the details, I will provide the over-arching idea behind what you're wanting to accomplish.

Coming in here asking about how to transfer data from a php based CMS to a remote C++ application doesn't leave all that many avenues to travel, however the vehicles that are used on those avenues are numerous (hence my "million and one" comments).

If I remember right, you never said anything about "polling" in your original question. I'm no mind reader, so how would I know this?

Okay, so you don't want to built a client-server relation into your programs using sockets, what other ways could you get the data across? There's writing and reading a file utilizing some sort of other client-server like an http or nfs (such as the popular samba) for the actual transfer of the data. What other avenues could you travel down? You could get down and dirty and write your own networking protocol! But, no matter what you decide on doing, the solution will rely one way or another on a client-server model and most likely there will be polling somewhere.

My comments about you being as helpful as saritha isn't that hard to comprehend. saritha didn't provide much info about what they were wanting to do and what constraints there were, much less reply after others had given ideas on how to accomplish the task.

I may not know who you are jrb, for all I know you could be a gifted programmer from Microsoft, a pimply faced tween who just learned how to write their first "Hello world!", or something in between. But I do know this, you don't come to a place and start throwing your weight around as soon as you get there. We're not Google here. I gave you an answer that I myself have found on Google from my own past research in writing network applications.

By the way, I don't have a dog but I do have cats. You are welcome to come over and clean their sand and give Tigger his anti-crystal medication.
Was This Post Helpful? 0
  • +
  • -

#10 jrb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 01-July 07

Re: PASS DATA FROM PHP TO C

Posted 05 July 2007 - 04:06 AM

View Posthotsnoj, on 4 Jul, 2007 - 01:05 PM, said:

jrb, you're really trying my patience. I answer to the degree of the question. If you provide no code and are fuzzy on the details, I will provide the over-arching idea behind what you're wanting to accomplish.

Coming in here asking about how to transfer data from a php based CMS to a remote C++ application doesn't leave all that many avenues to travel, however the vehicles that are used on those avenues are numerous (hence my "million and one" comments).

If I remember right, you never said anything about "polling" in your original question. I'm no mind reader, so how would I know this?

Okay, so you don't want to built a client-server relation into your programs using sockets, what other ways could you get the data across? There's writing and reading a file utilizing some sort of other client-server like an http or nfs (such as the popular samba) for the actual transfer of the data. What other avenues could you travel down? You could get down and dirty and write your own networking protocol! But, no matter what you decide on doing, the solution will rely one way or another on a client-server model and most likely there will be polling somewhere.

My comments about you being as helpful as saritha isn't that hard to comprehend. saritha didn't provide much info about what they were wanting to do and what constraints there were, much less reply after others had given ideas on how to accomplish the task.

I may not know who you are jrb, for all I know you could be a gifted programmer from Microsoft, a pimply faced tween who just learned how to write their first "Hello world!", or something in between. But I do know this, you don't come to a place and start throwing your weight around as soon as you get there. We're not Google here. I gave you an answer that I myself have found on Google from my own past research in writing network applications.

By the way, I don't have a dog but I do have cats. You are welcome to come over and clean their sand and give Tigger his anti-crystal medication.


Thank you for your time and effort hotsnoj. If I had program code that would be of any help that I could send you I would send it. But the fact of the matter is, ideas have to be translated to code and I am not asking for help concerning a bug or a concept that I do not understand. My applications serve their purpose, but sometimes things can be done more efficiently.

I have a network of clients all running the same C application which polls and/or is interrupted through rs232 interfaces. The clients all have different jobs to do and they should listen to their master (being the SQL DB). The C application on the clients presently polls the server database for data that may be relevant for them. This, to me, does not seem to me to be a very elegant way of providing data to my clients. I thought that maybe, just maybe their may be a way (maybe even a million and one ways, though I doubt it) of pipe-lining data from PHP to C. Maybe more like one or two ways.

Anyway, information is written to the MySQL database using the PHP5 MySQL API. It would be nice to be able to, after storing the data in MySQL (this works just fine) say "hey there client 192.168.1.50 hold everything there, I have an important message for you!", Client 192.168.1.50 stops and LISTENS, takes his/her info and sends an acknowledge to the DB that he/she understands what he/she has been told (I can manage that part) and have him/her carry on with his/her task of rs232 monitoring.

My intention was not to insult anybody or throw my weight around. If you feel like being sarcastic then I can play that game too but I thought that this was a problem solving forum. I have not yet been convinced otherwise. In my opinion their is (just like my programming solution) a lot of unnecessary overhead resulting from a very simple question that even a pimply faced teen that just learned to write his first "hello world" can understand. Saritha asked a simple question and got an answer that not even a seasoned programmer could do anything at all with. I am quite sure their is a simple answer with out dogs and cats and pimply faced teens and a million and one nights...

I do hope your cat is doing well and am happy to hear that you do at least have a heart for animals. Have a nice day!

With kindest regards, jrb

P.S. Is that a weapon you are aiming? I hope you are not shooting cats for a hobby. Poor Tigger!!!

This post has been edited by jrb: 05 July 2007 - 11:42 AM

Was This Post Helpful? 0
  • +
  • -

#11 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: PASS DATA FROM PHP TO C

Posted 05 July 2007 - 03:50 PM

See, now there is a little more info that was very helpful to me to better understand your situation.

However, my original suggestion still stands. By using sockets with php and whatever C/C++ can use with your client applications, you can have you CMS tell your clients something is new or send them data. In this regard, the clients are "servers" and the CMS is a "client" (since the client is listening).

I'm no C/C++ buff, but I'm sure google will return a plethora of results for sockets (same with PHP). For PHP I suggest the pear NET_Socket package since it makes the use of sockets much simpler.

If you'll note, saritha asked an over arching question with no details on what they were doing except passing stuff between PHP and C. The answers given perfectly answer the question asked and any "seasoned" programmer wouldn't be asking that kind of question. Their question would probably be something more along the lines of "I'm trying to move some data around from my PHP script to an application made with C (Or vise-versa). Since both things are on the same machine and always will be, I can't decide if it would be better to pass info through sockets or if it would be better to write a php extension. Does anyone know which would be better and/or easier to do and why? Also, can anyone point me to a resource for these? I can't find many that explain the process in a way I can understand."

If you're not understanding what I'm trying to get at, please have a read of "How To Ask Questions The Smart Way" by Eric Steven Raymond. It's a very good resource for learning how to ask questions in a way that will get the desired reply. It's helped me a lot in looking for answers and in asking the right questions.

No that's not a weapon, though I suppose it could be used as such. It's actually a soldering gun and a really long night at my former employer. Here's a larger picture and another with the same gun, though slightly different pose. ;)
Was This Post Helpful? 0
  • +
  • -

#12 jrb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 01-July 07

Re: PASS DATA FROM PHP TO C

Posted 06 July 2007 - 02:49 AM

View Posthotsnoj, on 5 Jul, 2007 - 03:50 PM, said:

See, now there is a little more info that was very helpful to me to better understand your situation.

However, my original suggestion still stands. By using sockets with php and whatever C/C++ can use with your client applications, you can have you CMS tell your clients something is new or send them data. In this regard, the clients are "servers" and the CMS is a "client" (since the client is listening).

I'm no C/C++ buff, but I'm sure google will return a plethora of results for sockets (same with PHP). For PHP I suggest the pear NET_Socket package since it makes the use of sockets much simpler.

If you'll note, saritha asked an over arching question with no details on what they were doing except passing stuff between PHP and C. The answers given perfectly answer the question asked and any "seasoned" programmer wouldn't be asking that kind of question. Their question would probably be something more along the lines of "I'm trying to move some data around from my PHP script to an application made with C (Or vise-versa). Since both things are on the same machine and always will be, I can't decide if it would be better to pass info through sockets or if it would be better to write a php extension. Does anyone know which would be better and/or easier to do and why? Also, can anyone point me to a resource for these? I can't find many that explain the process in a way I can understand."

If you're not understanding what I'm trying to get at, please have a read of "How To Ask Questions The Smart Way" by Eric Steven Raymond. It's a very good resource for learning how to ask questions in a way that will get the desired reply. It's helped me a lot in looking for answers and in asking the right questions.

No that's not a weapon, though I suppose it could be used as such. It's actually a soldering gun and a really long night at my former employer. Here's a larger picture and another with the same gun, though slightly different pose. ;)

I understand very well where you are coming from and I did read "How to Ask Questions the Smart Way". I assumed that, although I tried to keep my question short, I got my message across properly. Thank you for your suggestions. I will delve into some more I-Surfing and if I happen to come up with a reasonable solution I will get it back here to the forum because I noticed that there are quite a few people interested in this particular thread.
Thanks again and give Tigger a pat on the head for me. Joe
Was This Post Helpful? 0
  • +
  • -

#13 ap0c0lyps3  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 83
  • Joined: 19-June 07

Re: PASS DATA FROM PHP TO C

Posted 07 July 2007 - 01:54 PM

You said that all the info was stored into a SQL database right? Well PHP has native support for MySql and some other SQL databases so....

By the way isn't saritha the guy who asked the question?

This post has been edited by ap0c0lyps3: 07 July 2007 - 01:57 PM

Was This Post Helpful? 0
  • +
  • -

#14 jrb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 01-July 07

Re: PASS DATA FROM PHP TO C

Posted 07 July 2007 - 02:41 PM

Yes and Yes. I am well aware that PHP has native SQL support. What exactly is your point?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1