add logging of PC92A ip addresses
[spider.git] / perl / Msg.pm
1 #
2 # This has been taken from the 'Advanced Perl Programming' book by Sriram Srinivasan 
3 #
4 # I am presuming that the code is distributed on the same basis as perl itself.
5 #
6 # I have modified it to suit my devious purposes (Dirk Koopman G1TLH)
7 #
8 #
9 #
10
11 package Msg;
12
13 use strict;
14
15 use DXUtil;
16
17 use IO::Select;
18 use DXDebug;
19 use Timer;
20
21 use vars qw(%rd_callbacks %wt_callbacks %er_callbacks $rd_handles $wt_handles $er_handles $now %conns $noconns $blocking_supported $cnum $total_in $total_out $io_socket);
22
23 %rd_callbacks = ();
24 %wt_callbacks = ();
25 %er_callbacks = ();
26 $rd_handles   = IO::Select->new();
27 $wt_handles   = IO::Select->new();
28 $er_handles   = IO::Select->new();
29 $total_in = $total_out = 0;
30
31 $now = time;
32
33 BEGIN {
34     # Checks if blocking is supported
35     eval {
36                 local $^W;
37         require POSIX; POSIX->import(qw(O_NONBLOCK F_SETFL F_GETFL))
38     };
39
40         eval {
41                 local $^W;
42                 require IO::Socket::INET6;
43         };
44
45         if ($@) {
46                 dbg($@);
47                 require IO::Socket;
48                 $io_socket = 'IO::Socket::INET';
49         } else {
50                 $io_socket = 'IO::Socket::INET6';
51         }
52         $io_socket->import;
53
54         if ($@ || $main::is_win) {
55                 $blocking_supported = $io_socket->can('blocking') ? 2 : 0;
56         } else {
57                 $blocking_supported = $io_socket->can('blocking') ? 2 : 1;
58         }
59
60
61         # import as many of these errno values as are available
62         eval {
63                 local $^W;
64                 require Errno; Errno->import(qw(EAGAIN EINPROGRESS EWOULDBLOCK));
65         };
66
67         unless ($^O eq 'MSWin32') {
68                 if ($] >= 5.6) {
69                         eval {
70                                 local $^W;
71                                 require Socket; Socket->import(qw(IPPROTO_TCP TCP_NODELAY));
72                         };
73                 } else {
74                         dbg("IPPROTO_TCP and TCP_NODELAY manually defined");
75                         eval 'sub IPPROTO_TCP {     6 };';
76                         eval 'sub TCP_NODELAY {     1 };';
77                 }
78         }
79         # http://support.microsoft.com/support/kb/articles/Q150/5/37.asp
80         # defines EINPROGRESS as 10035.  We provide it here because some
81         # Win32 users report POSIX::EINPROGRESS is not vendor-supported.
82         if ($^O eq 'MSWin32') { 
83                 eval '*EINPROGRESS = sub { 10036 };' unless defined *EINPROGRESS;
84                 eval '*EWOULDBLOCK = *EAGAIN = sub { 10035 };' unless defined *EWOULDBLOCK;
85                 eval '*F_GETFL     = sub {     0 };' unless defined *F_GETFL;
86                 eval '*F_SETFL     = sub {     0 };' unless defined *F_SETFL;
87                 eval 'sub IPPROTO_TCP  {     6 };';
88                 eval 'sub TCP_NODELAY  {     1 };';
89                 $blocking_supported = 0;   # it appears that this DOESN'T work :-(
90         } 
91 }
92
93 my $w = $^W;
94 $^W = 0;
95 my $eagain = eval {EAGAIN()};
96 my $einprogress = eval {EINPROGRESS()};
97 my $ewouldblock = eval {EWOULDBLOCK()};
98 $^W = $w;
99 $cnum = 0;
100
101
102 #
103 #-----------------------------------------------------------------
104 # Generalised initializer
105
106 sub new
107 {
108     my ($pkg, $rproc) = @_;
109         my $obj = ref($pkg);
110         my $class = $obj || $pkg;
111
112     my $conn = {
113         rproc => $rproc,
114                 inqueue => [],
115                 outqueue => [],
116                 state => 0,
117                 lineend => "\r\n",
118                 csort => 'telnet',
119                 timeval => 60,
120                 blocking => 0,
121                 cnum => (($cnum < 999) ? (++$cnum) : ($cnum = 1)),
122     };
123
124         $noconns++;
125         
126         dbg("Connection created ($noconns)") if isdbg('connll');
127         return bless $conn, $class;
128 }
129
130 sub set_error
131 {
132         my $conn = shift;
133         my $callback = shift;
134         $conn->{eproc} = $callback;
135         set_event_handler($conn->{sock}, error => $callback) if exists $conn->{sock};
136 }
137
138 sub set_rproc
139 {
140         my $conn = shift;
141         my $callback = shift;
142         $conn->{rproc} = $callback;
143 }
144
145 sub blocking
146 {
147         return unless $blocking_supported;
148
149         # Make the handle stop blocking, the Windows way.
150         if ($blocking_supported) { 
151                 $_[0]->blocking($_[1]);
152         } else {
153                 my $flags = fcntl ($_[0], F_GETFL, 0);
154                 if ($_[1]) {
155                         $flags &= ~O_NONBLOCK;
156                 } else {
157                         $flags |= O_NONBLOCK;
158                 }
159                 fcntl ($_[0], F_SETFL, $flags);
160         }
161 }
162
163 # save it
164 sub conns
165 {
166         my $pkg = shift;
167         my $call = shift;
168         my $ref;
169         
170         if (ref $pkg) {
171                 $call = $pkg->{call} unless $call;
172                 return undef unless $call;
173                 dbg("changing $pkg->{call} to $call") if isdbg('connll') && exists $pkg->{call} && $call ne $pkg->{call};
174                 delete $conns{$pkg->{call}} if exists $pkg->{call} && exists $conns{$pkg->{call}} && $pkg->{call} ne $call; 
175                 $pkg->{call} = $call;
176                 $ref = $conns{$call} = $pkg;
177                 dbg("Connection $pkg->{cnum} $call stored") if isdbg('connll');
178         } else {
179                 $ref = $conns{$call};
180         }
181         return $ref;
182 }
183
184 # this is only called by any dependent processes going away unexpectedly
185 sub pid_gone
186 {
187         my ($pkg, $pid) = @_;
188         
189         my @pid = grep {$_->{pid} == $pid} values %conns;
190         foreach my $p (@pid) {
191                 &{$p->{eproc}}($p, "$pid has gorn") if exists $p->{eproc};
192                 $p->disconnect;
193         }
194 }
195
196 sub peerhost
197 {
198         my $self = shift;
199         my $ip;
200         unless ($self->{peerhost}) {
201                 $self->{peerhost} = $self->{sock}->peerhost;
202         }
203         return $self->{peerhost};
204 }
205
206 #-----------------------------------------------------------------
207 # Send side routines
208 sub connect {
209     my ($pkg, $to_host, $to_port, $rproc) = @_;
210
211     # Create a connection end-point object
212     my $conn = $pkg;
213         unless (ref $pkg) {
214                 $conn = $pkg->new($rproc);
215         }
216         $conn->{peerhost} = $to_host;
217         $conn->{peerport} = $to_port;
218         $conn->{sort} = 'Outgoing';
219         
220     # Create a new internet socket
221     my $sock = $io_socket->new();
222     return undef unless $sock;
223         
224         my $proto = getprotobyname('tcp');
225         $sock->socket(AF_INET, SOCK_STREAM, $proto) or return undef;
226         
227         blocking($sock, 0);
228         $conn->{blocking} = 0;
229
230         # does the host resolve?
231         my $ip = gethostbyname($to_host);
232         return undef unless $ip;
233         
234         my $r = connect($sock, pack_sockaddr_in($to_port, $ip));
235         return undef unless $r || _err_will_block($!);
236         
237         $conn->{sock} = $sock;
238         $conn->{peerhost} = $sock->peerhost;    # for consistency
239
240     if ($conn->{rproc}) {
241         my $callback = sub {$conn->_rcv};
242         set_event_handler ($sock, read => $callback);
243     }
244     return $conn;
245 }
246
247 sub start_program
248 {
249         my ($conn, $line, $sort) = @_;
250         my $pid;
251         
252         local $^F = 10000;              # make sure it ain't closed on exec
253         my ($a, $b) = $io_socket->socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC);
254         if ($a && $b) {
255                 $a->autoflush(1);
256                 $b->autoflush(1);
257                 $pid = fork;
258                 if (defined $pid) {
259                         if ($pid) {
260                                 close $b;
261                                 $conn->{sock} = $a;
262                                 $conn->{csort} = $sort;
263                                 $conn->{lineend} = "\cM" if $sort eq 'ax25';
264                                 $conn->{pid} = $pid;
265                                 if ($conn->{rproc}) {
266                                         my $callback = sub {$conn->_rcv};
267                                         Msg::set_event_handler ($a, read => $callback);
268                                 }
269                                 dbg("connect $conn->{cnum}: started pid: $conn->{pid} as $line") if isdbg('connect');
270                         } else {
271                                 $^W = 0;
272                                 dbgclose();
273                                 STDIN->close;
274                                 STDOUT->close;
275                                 STDOUT->close;
276                                 *STDIN = IO::File->new_from_fd($b, 'r') or die;
277                                 *STDOUT = IO::File->new_from_fd($b, 'w') or die;
278                                 *STDERR = IO::File->new_from_fd($b, 'w') or die;
279                                 close $a;
280                                 unless ($main::is_win) {
281                                         #                                               $SIG{HUP} = 'IGNORE';
282                                         $SIG{HUP} = $SIG{CHLD} = $SIG{TERM} = $SIG{INT} = 'DEFAULT';
283                                         alarm(0);
284                                 }
285                                 exec "$line" or dbg("exec '$line' failed $!");
286                         } 
287                 } else {
288                         dbg("cannot fork for $line");
289                 }
290         } else {
291                 dbg("no socket pair $! for $line");
292         }
293         return $pid;
294 }
295
296 sub disconnect 
297 {
298     my $conn = shift;
299         return if exists $conn->{disconnecting};
300
301         $conn->{disconnecting} = 1;
302     my $sock = delete $conn->{sock};
303         $conn->{state} = 'E';
304         $conn->{timeout}->del if $conn->{timeout};
305
306         # be careful to delete the correct one
307         my $call;
308         if ($call = $conn->{call}) {
309                 my $ref = $conns{$call};
310                 delete $conns{$call} if $ref && $ref == $conn;
311         }
312         $call ||= 'unallocated';
313         dbg("Connection $conn->{cnum} $call disconnected") if isdbg('connll');
314         
315         # get rid of any references
316         for (keys %$conn) {
317                 if (ref($conn->{$_})) {
318                         delete $conn->{$_};
319                 }
320         }
321
322         if (defined($sock)) {
323                 set_event_handler ($sock, read => undef, write => undef, error => undef);
324                 shutdown($sock, 3);
325                 close($sock);
326         }
327         
328         unless ($main::is_win) {
329                 kill 'TERM', $conn->{pid} if exists $conn->{pid};
330         }
331 }
332
333 sub send_now {
334     my ($conn, $msg) = @_;
335     $conn->enqueue($msg);
336     $conn->_send (1); # 1 ==> flush
337 }
338
339 sub send_later {
340     my ($conn, $msg) = @_;
341     $conn->enqueue($msg);
342     my $sock = $conn->{sock};
343     return unless defined($sock);
344     set_event_handler ($sock, write => sub {$conn->_send(0)});
345 }
346
347 sub enqueue {
348     my $conn = shift;
349     push (@{$conn->{outqueue}}, defined $_[0] ? $_[0] : '');
350 }
351
352 sub _send {
353     my ($conn, $flush) = @_;
354     my $sock = $conn->{sock};
355     return unless defined($sock);
356     my $rq = $conn->{outqueue};
357
358     # If $flush is set, set the socket to blocking, and send all
359     # messages in the queue - return only if there's an error
360     # If $flush is 0 (deferred mode) make the socket non-blocking, and
361     # return to the event loop only after every message, or if it
362     # is likely to block in the middle of a message.
363
364 #       if ($conn->{blocking} != $flush) {
365 #               blocking($sock, $flush);
366 #               $conn->{blocking} = $flush;
367 #       }
368     my $offset = (exists $conn->{send_offset}) ? $conn->{send_offset} : 0;
369
370     while (@$rq) {
371         my $msg            = $rq->[0];
372                 my $mlth           = length($msg);
373         my $bytes_to_write = $mlth - $offset;
374         my $bytes_written  = 0;
375                 confess("Negative Length! msg: '$msg' lth: $mlth offset: $offset") if $bytes_to_write < 0;
376         while ($bytes_to_write > 0) {
377             $bytes_written = syswrite ($sock, $msg,
378                                        $bytes_to_write, $offset);
379             if (!defined($bytes_written)) {
380                 if (_err_will_block($!)) {
381                     # Should happen only in deferred mode. Record how
382                     # much we have already sent.
383                     $conn->{send_offset} = $offset;
384                     # Event handler should already be set, so we will
385                     # be called back eventually, and will resume sending
386                     return 1;
387                 } else {    # Uh, oh
388                                         &{$conn->{eproc}}($conn, $!) if exists $conn->{eproc};
389                                         $conn->disconnect;
390                     return 0; # fail. Message remains in queue ..
391                 }
392             } elsif (isdbg('raw')) {
393                                 my $call = $conn->{call} || 'none';
394                                 dbgdump('raw', "$call send $bytes_written: ", $msg);
395                         }
396                         $total_out      += $bytes_written;
397             $offset         += $bytes_written;
398             $bytes_to_write -= $bytes_written;
399         }
400         delete $conn->{send_offset};
401         $offset = 0;
402         shift @$rq;
403         #last unless $flush; # Go back to select and wait
404                             # for it to fire again.
405     }
406     # Call me back if queue has not been drained.
407     unless (@$rq) {
408         set_event_handler ($sock, write => undef);
409                 if (exists $conn->{close_on_empty}) {
410                         &{$conn->{eproc}}($conn, undef) if exists $conn->{eproc};
411                         $conn->disconnect; 
412                 }
413     }
414     1;  # Success
415 }
416
417 sub dup_sock
418 {
419         my $conn = shift;
420         my $oldsock = $conn->{sock};
421         my $rc = $rd_callbacks{$oldsock};
422         my $wc = $wt_callbacks{$oldsock};
423         my $ec = $er_callbacks{$oldsock};
424         my $sock = $oldsock->new_from_fd($oldsock, "w+");
425         if ($sock) {
426                 set_event_handler($oldsock, read=>undef, write=>undef, error=>undef);
427                 $conn->{sock} = $sock;
428                 set_event_handler($sock, read=>$rc, write=>$wc, error=>$ec);
429                 $oldsock->close;
430         }
431 }
432
433 sub _err_will_block {
434         return 0 unless $blocking_supported;
435         return ($_[0] == $eagain || $_[0] == $ewouldblock || $_[0] == $einprogress);
436 }
437
438 sub close_on_empty
439 {
440         my $conn = shift;
441         $conn->{close_on_empty} = 1;
442 }
443
444 #-----------------------------------------------------------------
445 # Receive side routines
446
447 sub new_server {
448     @_ == 4 || die "Msg->new_server (myhost, myport, login_proc\n";
449     my ($pkg, $my_host, $my_port, $login_proc) = @_;
450         my $self = $pkg->new($login_proc);
451         
452     $self->{sock} = $io_socket->new (
453                                           LocalAddr => "$my_host:$my_port",
454 #                                          LocalPort => $my_port,
455                                           Listen    => SOMAXCONN,
456                                           Proto     => 'tcp',
457                                           Reuse => 1);
458     die "Could not create socket: $! \n" unless $self->{sock};
459     set_event_handler ($self->{sock}, read => sub { $self->new_client }  );
460         return $self;
461 }
462
463
464 sub nolinger
465 {
466         my $conn = shift;
467
468         unless ($main::is_win) {
469                 if (isdbg('sock')) {
470                         my ($l, $t) = unpack "ll", getsockopt($conn->{sock}, SOL_SOCKET, SO_LINGER); 
471                         my $k = unpack 'l', getsockopt($conn->{sock}, SOL_SOCKET, SO_KEEPALIVE);
472                         my $n = $main::is_win ? 0 : unpack "l", getsockopt($conn->{sock}, IPPROTO_TCP, TCP_NODELAY);
473                         dbg("Linger is: $l $t, keepalive: $k, nagle: $n");
474                 }
475                 
476                 eval {setsockopt($conn->{sock}, SOL_SOCKET, SO_KEEPALIVE, 1)} or dbg("setsockopt keepalive: $!");
477                 eval {setsockopt($conn->{sock}, SOL_SOCKET, SO_LINGER, pack("ll", 0, 0))} or dbg("setsockopt linger: $!");
478                 eval {setsockopt($conn->{sock}, IPPROTO_TCP, TCP_NODELAY, 1)} or eval {setsockopt($conn->{sock}, SOL_SOCKET, TCP_NODELAY, 1)} or dbg("setsockopt tcp_nodelay: $!");
479                 $conn->{sock}->autoflush(0);
480
481                 if (isdbg('sock')) {
482                         my ($l, $t) = unpack "ll", getsockopt($conn->{sock}, SOL_SOCKET, SO_LINGER); 
483                         my $k = unpack 'l', getsockopt($conn->{sock}, SOL_SOCKET, SO_KEEPALIVE);
484                         my $n = $main::is_win ? 0 : unpack "l", getsockopt($conn->{sock}, IPPROTO_TCP, TCP_NODELAY);
485                         dbg("Linger is: $l $t, keepalive: $k, nagle: $n");
486                 }
487         } 
488 }
489
490 sub dequeue
491 {
492         my $conn = shift;
493
494         if ($conn->{msg} =~ /\n/) {
495                 my @lines = split /\r?\n/, $conn->{msg};
496                 if ($conn->{msg} =~ /\n$/) {
497                         delete $conn->{msg};
498                 } else {
499                         $conn->{msg} = pop @lines;
500                 }
501                 for (@lines) {
502                         &{$conn->{rproc}}($conn, defined $_ ? $_ : '');
503                 }
504         }
505 }
506
507 sub _rcv {                     # Complement to _send
508     my $conn = shift; # $rcv_now complement of $flush
509     # Find out how much has already been received, if at all
510     my ($msg, $offset, $bytes_to_read, $bytes_read);
511     my $sock = $conn->{sock};
512     return unless defined($sock);
513
514         my @lines;
515 #       if ($conn->{blocking}) {
516 #               blocking($sock, 0);
517 #               $conn->{blocking} = 0;
518 #       }
519         $bytes_read = sysread ($sock, $msg, 1024, 0);
520         if (defined ($bytes_read)) {
521                 if ($bytes_read > 0) {
522                         $total_in += $bytes_read;
523                         if (isdbg('raw')) {
524                                 my $call = $conn->{call} || 'none';
525                                 dbgdump('raw', "$call read $bytes_read: ", $msg);
526                         }
527                         if ($conn->{echo}) {
528                                 my @ch = split //, $msg;
529                                 my $out;
530                                 for (@ch) {
531                                         if (/[\cH\x7f]/) {
532                                                 $out .= "\cH \cH";
533                                                 $conn->{msg} =~ s/.$//;
534                                         } else {
535                                                 $out .= $_;
536                                                 $conn->{msg} .= $_;
537                                         }
538                                 }
539                                 if (defined $out) {
540                                         set_event_handler ($sock, write => sub{$conn->_send(0)});
541                                         push @{$conn->{outqueue}}, $out;
542                                 }
543                         } else {
544                                 $conn->{msg} .= $msg;
545                         }
546                 } 
547         } else {
548                 if (_err_will_block($!)) {
549                         return ; 
550                 } else {
551                         $bytes_read = 0;
552                 }
553     }
554
555 FINISH:
556     if (defined $bytes_read && $bytes_read == 0) {
557                 &{$conn->{eproc}}($conn, $!) if exists $conn->{eproc};
558                 $conn->disconnect;
559     } else {
560                 unless ($conn->{disable_read}) {
561                         $conn->dequeue if exists $conn->{msg};
562                 }
563         }
564 }
565
566 sub new_client {
567         my $server_conn = shift;
568     my $sock = $server_conn->{sock}->accept();
569         if ($sock) {
570                 my $conn = $server_conn->new($server_conn->{rproc});
571                 $conn->{sock} = $sock;
572                 blocking($sock, 0);
573                 $conn->nolinger;
574                 $conn->{blocking} = 0;
575                 my ($rproc, $eproc) = &{$server_conn->{rproc}} ($conn, $conn->{peerhost} = $sock->peerhost(), $conn->{peerport} = $sock->peerport());
576                 $conn->{sort} = 'Incoming';
577                 if ($eproc) {
578                         $conn->{eproc} = $eproc;
579                         set_event_handler ($sock, error => $eproc);
580                 }
581                 if ($rproc) {
582                         $conn->{rproc} = $rproc;
583                         my $callback = sub {$conn->_rcv};
584                         set_event_handler ($sock, read => $callback);
585                 } else {  # Login failed
586                         &{$conn->{eproc}}($conn, undef) if exists $conn->{eproc};
587                         $conn->disconnect();
588                 }
589         } else {
590                 dbg("Msg: error on accept ($!)") if isdbg('err');
591         }
592 }
593
594 sub close_server
595 {
596         my $conn = shift;
597         set_event_handler ($conn->{sock}, read => undef, write => undef, error => undef );
598         $conn->{sock}->close;
599 }
600
601 # close all clients (this is for forking really)
602 sub close_all_clients
603 {
604         foreach my $conn (values %conns) {
605                 $conn->disconnect;
606         }
607 }
608
609 sub disable_read
610 {
611         my $conn = shift;
612         set_event_handler ($conn->{sock}, read => undef);
613         return $_[0] ? $conn->{disable_read} = $_[0] : $_[0];
614 }
615
616 #
617 #----------------------------------------------------
618 # Event loop routines used by both client and server
619
620 sub set_event_handler {
621     shift unless ref($_[0]); # shift if first arg is package name
622     my ($handle, %args) = @_;
623     my $callback;
624     if (exists $args{'write'}) {
625         $callback = $args{'write'};
626         if ($callback) {
627             $wt_callbacks{$handle} = $callback;
628             $wt_handles->add($handle);
629         } else {
630             delete $wt_callbacks{$handle};
631             $wt_handles->remove($handle);
632         }
633     }
634     if (exists $args{'read'}) {
635         $callback = $args{'read'};
636         if ($callback) {
637             $rd_callbacks{$handle} = $callback;
638             $rd_handles->add($handle);
639         } else {
640             delete $rd_callbacks{$handle};
641             $rd_handles->remove($handle);
642        }
643     }
644     if (exists $args{'error'}) {
645         $callback = $args{'error'};
646         if ($callback) {
647             $er_callbacks{$handle} = $callback;
648             $er_handles->add($handle);
649         } else {
650             delete $er_callbacks{$handle};
651             $er_handles->remove($handle);
652        }
653     }
654 }
655
656 sub event_loop {
657     my ($pkg, $loop_count, $timeout, $wronly) = @_; # event_loop(1) to process events once
658     my ($conn, $r, $w, $e, $rset, $wset, $eset);
659     while (1) {
660  
661        # Quit the loop if no handles left to process
662                 if ($wronly) {
663                         last unless $wt_handles->count();
664         
665                         ($rset, $wset, $eset) = IO::Select->select(undef, $wt_handles, undef, $timeout);
666                         
667                         foreach $w (@$wset) {
668                                 &{$wt_callbacks{$w}}($w) if exists $wt_callbacks{$w};
669                         }
670                 } else {
671                         
672                         last unless ($rd_handles->count() || $wt_handles->count());
673         
674                         ($rset, $wset, $eset) = IO::Select->select($rd_handles, $wt_handles, $er_handles, $timeout);
675                         
676                         foreach $e (@$eset) {
677                                 &{$er_callbacks{$e}}($e) if exists $er_callbacks{$e};
678                         }
679                         foreach $r (@$rset) {
680                                 &{$rd_callbacks{$r}}($r) if exists $rd_callbacks{$r};
681                         }
682                         foreach $w (@$wset) {
683                                 &{$wt_callbacks{$w}}($w) if exists $wt_callbacks{$w};
684                         }
685                 }
686
687                 Timer::handler;
688                 
689         if (defined($loop_count)) {
690             last unless --$loop_count;
691         }
692     }
693 }
694
695 sub sleep
696 {
697         my ($pkg, $interval) = @_;
698         my $now = time;
699         while (time - $now < $interval) {
700                 $pkg->event_loop(10, 0.01);
701         }
702 }
703
704 sub DESTROY
705 {
706         my $conn = shift;
707         my $call = $conn->{call} || 'unallocated';
708         my $host = $conn->{peerhost} || '';
709         my $port = $conn->{peerport} || '';
710         dbg("Connection $conn->{cnum} $call [$host $port] being destroyed") if isdbg('connll');
711         $noconns--;
712 }
713
714 1;
715
716 __END__
717