Re: Gtk::io patch

On 07/13/01 Jim Edwards wrote:
Paolo Molaro wrote:

timeout is best handled with a sub timeout {} as described in the
IO::Socket manpage (ie a setter/getter method). This means that
once you created an IO::Socket::INET, for example, and rebless it to
Gtk::io::INET, you can just use:

        $socket->timeout (NEW_TIMEOUT);

But this doesn´t seem to work with Gtk::io,  the timeout in _sweeper is independent of the IO::Socket 
timeout .

Gtk::io works this way: you create your usual socket, say IO::Socket::INET,
and re-bless the reference to the proper Gtk::io::* package:

        my $socket = IO::Socket::INET->new (...);
        bless $socket, 'Gtk::io::INET';

Now, look at @Gtk::io::INET::ISA :
@ISA = qw(Gtk::io IO::Socket::INET);

So, if you create a timeout method in Gtk::io, it is found before
the one in IO::Socket. If the method is simply a wrapper for setting 
the existing $timeout variable, it will be effectively a global change, 
but Gtk::io can easily be reworked to use a per-socket timeout.
To make it work per-socket, just use $socket->timeout in the sweeper
routine (note that it works with fds, now, so it would need some

I would be open to making the two mechanisms work together.   Attached is another patch for that
you may find a little more to your liking.  But I´ve been playing with IO::Socket::timeout for a couple of 
hours now and

I cannot make anything timeout through that mechanism.  This patch doesn´t so much work with it as override 

Either use and change the current $timeout scalar (ignoring the
IO::Socket one) or refactor the sweeper func to access the timeout
from IO::Socket. The first option is the easy one, though not a
complete solution.

What do you think?  (oh and have a nice weekend)

Well, it's a nice weekend, especially when next week is also vacation time:-)


lupus debian org                                     debian/rules
lupus ximian com                             Monkeys do it better

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