Re: Perl, GTK, Network



I'll just pass an example:


my $vyc = Net::Vypress::Chat->new;

# listen on udp
my $listen = Gtk2::Helper->add_watch ( $vyc->{'listen'}->fileno, "in", sub { do_stuff($vyc->{'listen'}); } );

sub do_stuff {
    my $listen = shift;
    my $buffer;
    $listen->recv($buffer, 1024);
    my @r = $vyc->recognise($buffer);
    my $type = shift @r;


    if ($type eq "chat") {
        my ($who, $text, $chan) = @r;
        add_text($buffer{$chan}, "<$who> $text");
    }
    .....
}

and the $vyc->{'listen'} is:

$self->{'listen'} = IO::Socket::INET->new (
  LocalPort => $self->{'port'},
  ReuseAddr => 1,
  Proto    => 'udp') || croak ("Can't establish"
  ." listen socket: $!");

--
Sincerely, ArtÅras 'arturaz' Ålajus
You can find me at:
irc.freenode.org: nick arturaz
irc.data.lt: nick arturaz
ICQ: 157929934
Jabber: arturaz akl lt




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