phpgtk + non-blocking sockets (2 viewing) (2) Guests
Favoured: 0
|
|
|
TOPIC: phpgtk + non-blocking sockets
|
|
|
|
phpgtk + non-blocking sockets 4 Years, 1 Month ago
|
Karma: 0
|
|
Hi,
i am using non-blocking sockets in my application, polling data by a Gtk::timeout_add() timer which has a timeout of .25 secs and autorestarts. that solution is kinda bad, because while moving the window the window laggs. cpu usage is okay when polling @.25 secs, but i guess its kinda unpretty solution.
how to realize sockets in phpgtk?
mfg RR
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
kksou (Admin)
Admin
Posts: 1599
|
|
Re:phpgtk + non-blocking sockets 4 Years, 1 Month ago
|
Karma: 23
|
|
Verlustmeldung wrote:
i am using non-blocking sockets in my application, polling data by a Gtk::timeout_add() timer which has a timeout of .25 secs and autorestarts. that solution is kinda bad, because while moving the window the window laggs. cpu usage is okay when polling @.25 secs, but i guess its kinda unpretty solution.
how to realize sockets in phpgtk?
Hi Verlustmeldung,
Would you want to give a bit more details so that I can give a more relevant example?
I'm not too sure if your problem is with the socket portion or the window lag. Seems like your socket portion is working fine. It's just the window lag that's bothering you.
Have you tried using Gtk::idle_add() instead?
Would be even better if you could post some of your codes here so that I can try to find out where the problem is (instead of having to think of a completely new example that might not be relevant to you.)
Regards,
/kksou
|
|
|
|
|
|
|
Last Edit: 2008/04/15 01:52 By kksou.
|
|
|
The administrator has disabled public write access.
|
|
|
|
Re:phpgtk + non-blocking sockets 4 Years, 1 Month ago
|
Karma: 0
|
|
i read about the idle_add() function but i dont have a clue how to use it. do you have an example somewhere?
i started to rewrite my application using gladewin32 as i think its pretty just dividing code from design.
when im writing the network stuff and experience such problems with window lag again i'll post full sniplets here.
do you have any idea why i havent got the constants "Gtk::IO_IN", etc ready? is this a window problem? im using a current gtk2 + php 5.2.5.
mfg RR
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
kksou (Admin)
Admin
Posts: 1599
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
Re:phpgtk + non-blocking sockets 4 Years, 1 Month ago
|
Karma: 0
|
|
jeah, the progress bar tut made it. works really kickass awesome :)
those IO_X consts dont work for me, i already tried that out.
* Gtk::IO_IN : stream is ready for reading,
* Gtk::IO_OUT : stream is ready for writing,
* Gtk::IO_PRI : this is the high priority channel for stream
* Gtk::IO_ERR : stream is in error state,
* Gtk::IO_HUP : stream has been disconnected (sighup)
* Gtk::IO_NVAL : (invalid command to socket ?)
what i am using now is:
$this->irc_listen_handle = Gtk::idle_add(array(&$this,'irc_listen'));
which calls
function irc_listen () {
while(1) {
usleep(0.1*1000*1000);
if ( $this->irc_conn ) {
$this->irc_conn->listen();
}
// care for whats going in the loop
while (Gtk::events_pending()) {Gtk::main_iteration();} // note 6
if ( $this->irc_stop_listen ) {
$this->irc_stop_listen = false;
if ( $this->irc_listen_handle ) {
Gtk::idle_remove($this->irc_listen_handle);
}
break;
}
}
}
if i set the irc_stop_listen = true the while loop gets killed.
mfg RR
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
Re:phpgtk + non-blocking sockets 4 Years, 1 Month ago
|
Karma: 0
|
http://php-gtk.eu/phpgtk-2-is-here#comment-90
found out why Gtk::IO_* didnt worked, it's GObject:IO_*
mfg RR
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
|