gibbonuk Posted August 2, 2011 Share Posted August 2, 2011 Hi, just wondering the best way to go about this. I have my own web server hosting my PHP website and i want to communicate with a local application (programming by myself in delphi) that with a request from PHP *does somthing* and returns some small data to PHP or puts the data directly into an sql DB for php to read it. I orginally thought about the "php request" to go into a mysql database where my application is always "looking" for a request, but its not really viable and im sure there are better ways. Anyone got some good ideas! Thanks Quote Link to comment Share on other sites More sharing options...
trq Posted August 2, 2011 Share Posted August 2, 2011 It would be easier to do it the other way around and have the client request the server like normal. Otherwise, your going to need to write a server into your client side application. Quote Link to comment Share on other sites More sharing options...
gibbonuk Posted August 2, 2011 Author Share Posted August 2, 2011 Hi, ok but im still unsure how i go about actually send data from a php page to a delphi app, or any application? There both stored on the server so surly there is a way? Thanks Andy Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted August 2, 2011 Share Posted August 2, 2011 Are you sure you need to run another app? For delphi you can read the contents of the tWebBrowser Address Bar into a string, so you can manipulate any variables from PHP that are sent through the URL using GET. Quote Link to comment Share on other sites More sharing options...
gibbonuk Posted August 2, 2011 Author Share Posted August 2, 2011 Ok, ill explain more whats happening. I have a delphi app that collects data from some hardware through the serial port, that all works ETC. It collects the data every 30 mins and puts it into a mysql database every 30 mins. But, what i would like is to let users go onto a webpage, press a button and it sends a message to the delphi app to go collect the data, instead of waiting for the next 30 minute request. I have a my own web host server, running the php website that display the data from the mysql, and also the delphi app is running on that webserver. The bit i dont know how to do is, the part when the user presses a button/link/dont mind and which tells the delphi app to do whatever. Thanks Andy Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted August 2, 2011 Share Posted August 2, 2011 There are a couple of ways that you could do it. If you write a copy of your update program without the timer component and have it run the update without a visible form then auto application.terminate when it has completed the update you could call that application using a shellexe() function from php. Alternativly you could set up an Indy listerning server in your current app and fire a command through to it from the php page that initates the update. Either way, the pascal will be a bigger pain than the PHP will be. Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 2, 2011 Share Posted August 2, 2011 There are ways to do "push" functionality with a web server, but I am no means an expert on it. Is there some reason you cannot simply increase the polling frequency for your delphi app? If it is a process that take a lot of time/resources I can think of one simple solution with regular "pull" functionality. On the web app allow users to select an option to have new data collected which, in turn, stores a flag in the database. Also, have the delphi app store a timestamp in the database every time it performs the operation to collect & store new data. Lastly, increase the polling of the delphi app to 1 minute (or whatever interval you choose) and instead of it automatically performing the data collecting process, instead have it make a call to the web app. Use that call to a PHP script which will determine if new data need to be collecting using the following logic: if 1) the flag has been set in the database (remember to clear the flag) OR 2) it has been at least 30 minutes since the last time data was collected. Although, the delphi app would be doing a call to the web app every minute it wouldn't perform the data collecting/updating process unless someone requested an update or the data is 30 minutes old. The call it makes to make that check would be minor and shouldn't have any performance/resource issues. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.