… | |
… | |
113 | my $self = bless { @_ }, $class; |
113 | my $self = bless { @_ }, $class; |
114 | |
114 | |
115 | $self->{host} ||= $ENV{FREDHOST} || "127.0.0.1"; |
115 | $self->{host} ||= $ENV{FREDHOST} || "127.0.0.1"; |
116 | $self->{port} ||= $ENV{FREDPORT} || 9481; |
116 | $self->{port} ||= $ENV{FREDPORT} || 9481; |
117 | $self->{name} ||= time.rand.rand.rand; # lame |
117 | $self->{name} ||= time.rand.rand.rand; # lame |
118 | $self->{timeout} ||= 600; |
118 | $self->{timeout} ||= 3600*2; |
119 | $self->{progress} ||= sub { }; |
119 | $self->{progress} ||= sub { }; |
120 | |
120 | |
121 | $self->{id} = "a0"; |
121 | $self->{id} = "a0"; |
122 | |
122 | |
123 | { |
123 | { |
… | |
… | |
125 | |
125 | |
126 | $self->{hdl} = new AnyEvent::Handle |
126 | $self->{hdl} = new AnyEvent::Handle |
127 | connect => [$self->{host} => $self->{port}], |
127 | connect => [$self->{host} => $self->{port}], |
128 | timeout => $self->{timeout}, |
128 | timeout => $self->{timeout}, |
129 | on_error => sub { |
129 | on_error => sub { |
130 | warn "<@_>\n"; |
130 | warn "@_\n";#d# |
131 | exit 1; |
131 | exit 1; |
132 | }, |
132 | }, |
133 | on_read => sub { $self->on_read (@_) }, |
133 | on_read => sub { $self->on_read (@_) }, |
134 | on_eof => $self->{on_eof} || sub { }; |
134 | on_eof => $self->{on_eof} || sub { }; |
135 | |
135 | |