ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Net-Knuddels/eg/knuddel
Revision: 1.1
Committed: Thu Jan 13 00:56:02 2005 UTC (19 years, 8 months ago) by elmex
Branch: MAIN
Log Message:
first client code

File Contents

# Content
1 #!/usr/bin/perl
2 use strict;
3 use Net::Knuddels;
4 use IO::Socket;
5 use IO::Handle;
6 use IO::Socket::INET;
7
8 sub new_socks {
9 my ($host, $port) = @_;
10
11 my $s = IO::Socket::INET->new (
12 PeerAddr => $host,
13 PeerPort => $port,
14 Proto => 'tcp'
15 );
16
17 die "Couldn't make socket to ${host}:${port}: $!\n";
18 }
19
20 my $knudi = Net::Knuddels::Protocol->new ();
21
22 my %channels;
23
24 $knudi->register ('b' => sub {
25 for (@_) {
26 if ($_ ne "-") {
27
28 } else {
29
30
31 }
32 }
33 });
34
35 my $sock = new_socks ($ARGV[0], $ARGV[1]);
36
37 my $clw = Event->io (
38 fd => $sock,
39 poll => 'r',
40 cb => sub {
41 my $data;
42 $sock->sysread ($data, 1000);
43 $knudi->feed_data ($data);
44 });
45
46