Re: Gtk::Gdk->input_add() ?????



It looks as though the culprit is "sleep".  I have found that as sleep
uses the alarm signal it is incompatible with GTK+. Instead use
Gtk->timeout_add(...).  When I had a similar problem that solved it.

Do something like:
sub yo{ print $client "YO"; return 1;}  #return 1 says do it repeatedly
                                        #return 0 says not again

then replace the while(1) line with:
Gtk->timeout_add(5000,\&yo,0);

This will even allow the accept loop to repeatedly accept...

--john

From: "Jon Oringer" <jon advercast com>

I'm having some problems with the input_add() function to assign a callback
to a socket when data is ready to be read from the socket.  Here is a simply
client/server program.. I have no idea why it doesn't work:



######################SERVER START
#!/usr/bin/perl
use strict;
use IO::Socket;
my $s = IO::Socket::INET->new(LocalPort => 9009, Type => SOCK_STREAM, Reuse
=> 1, Listen => 10)
        or die "cannot serve\n";
my $client;
while($client = $s->accept()) {
        while(1) { print $client "YO"; sleep 5;}
}
close($s);
######################SERVER END


-- 
John McDermott, Writer and Consultant
J-K International, Ltd.
V +1 505/377-6293  F +1 505/377-6313
jjm jkintl com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]