PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
web proxy server output to a PHP-GTK2 app? (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: web proxy server output to a PHP-GTK2 app?


#1828
alkino (User)
Fresh Boarder
Posts: 5
graphgraph
User Offline Click here to see the profile of this user
web proxy server output to a PHP-GTK2 app? 4 Years, 1 Month ago Karma: 0  
hello!
i am trying to develop a proxy web server. i have developed a proxy using sockets with a command line script. what i want to do is to display the http messages and all the information coming from the script in the gtktextviews. but what i get is infinite loops and my program is not responding. I have tried many ways to do this, even gtk::timeout_add but it starts showing my windows when there are incoming data from browser... if i use a 'start proxy' button it looks like i have infinite loop again and i can't use anything else but only kill the window! another third way i tried was to use a gtknotebook. the first page of the notebook is the results from proxy and the other pages have other things that i need... this does not work either...
do you know any way to display the output from my proxy script to textviews?? i am really desperate!
thanks in advance.
 
  The administrator has disabled public write access.

#1829
Burnt Okra (User)
Junior Boarder
Posts: 20
graphgraph
User Offline Click here to see the profile of this user
Re:web proxy server output to a PHP-GTK2 app? 4 Years, 1 Month ago Karma: 0  
You need to put a call to sleep() inside the while loop in your daemon process, otherwise it will eat up CPU cycles.

As for capturing data read from a socket and sending it to the GUI process, you need to use proc_open and related functions to spawn the daemon as a separate process and set up some pipes that the two processes can use to communicate with each other.
 
  The administrator has disabled public write access.

#1832
alkino (User)
Fresh Boarder
Posts: 5
graphgraph
User Offline Click here to see the profile of this user
Re:web proxy server output to a PHP-GTK2 app? 4 Years, 1 Month ago Karma: 0  
well i have to say that things are getting better... thanks a lot! but now my problem is that i don't understand where i should call the proc_open function etc. i have written a piece of code that sets up the pipes so I have the output from proxy into variables. if I call this piece of code from my callback when pressing a button, which makes the proxy run, then it never comes out from the callback...

just to make things clearer... i have 2 buttons, one that starts the proxy and another that stops the proxy. if i press start then textviews are filled with data from proxy and the second button turns sensitive so that I can press it later to stop proxy from running. what i get right now is having the start button forever pressed....what should i do?
 
  The administrator has disabled public write access.
#1833
Burnt Okra (User)
Junior Boarder
Posts: 20
graphgraph
User Offline Click here to see the profile of this user
Re:web proxy server output to a PHP-GTK2 app? 4 Years, 1 Month ago Karma: 0  
How is the proxy designed? proc_open would be called when you click the Start button. It would start the daemon as a separate process. You would also set up the pipes in the same function call. No need to do it separately.

I would actually use three processes here.

(1) The GTK app, or GUI.

(2) A process monitor with a while loop that conveys commands from the GUI to the daemon, checks the daemon's status, and conveys data from the daemon to the GUI.

(3) The daemon itself. The daemon would have a while loop that checks the port for data. It would also check a member variable to see if the halt command has been sent. It wouldn't communicate with the GUI directly. The GUI and the daemon would both be clients of the monitor.

The trick is to pass data and commands using different class methods than the method containing the loop, and periodically query them from inside the while loop. For example, the loop might check a variable called $this->haltCommandReceived, and break out of the loop and exit if it was set to true.
 
  The administrator has disabled public write access.



Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Links - Classes - Social Business - BPM - Web - General
Copyright © 2006-2013. kksou.com. All Rights Reserved