--- loncom/LondConnection.pm 2003/09/30 10:46:57 1.11 +++ loncom/LondConnection.pm 2003/10/27 10:09:37 1.13 @@ -1,7 +1,7 @@ # This module defines and implements a class that represents # a connection to a lond daemon. # -# $Id: LondConnection.pm,v 1.11 2003/09/30 10:46:57 foxr Exp $ +# $Id: LondConnection.pm,v 1.13 2003/10/27 10:09:37 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -38,20 +38,30 @@ use Crypt::IDEA; use LONCAPA::Configuration; use LONCAPA::HashIterator; + + + my $DebugLevel=0; +my %hostshash; +my %perlvar; # Read the configuration file for apache to get the perl # variable set. -my $perlvarref = LONCAPA::Configuration::read_conf('loncapa.conf'); -my %perlvar = %{$perlvarref}; -my $hoststab = - LONCAPA::Configuration::read_hosts( - "$perlvar{'lonTabDir'}/hosts.tab") || - die "Can't read host table!!"; -my %hostshash = %{$hoststab}; +sub ReadConfig { + my $perlvarref = LONCAPA::Configuration::read_conf('loncapa.conf'); + %perlvar = %{$perlvarref}; + my $hoststab = + LONCAPA::Configuration::read_hosts( + "$perlvar{'lonTabDir'}/hosts.tab") || + die "Can't read host table!!"; + %hostshash = %{$hoststab}; + + close(CONFIG); +} + -close(CONFIG); +ReadConfig; # Make sure it gets read on init. sub Debug { my $level = shift; @@ -65,7 +75,7 @@ sub Debug { =head2 Dump -Dump the internal state of the object: For debugging purposes. +Dump the internal state of the object: For debugging purposes, to stderr. =cut @@ -75,7 +85,7 @@ sub Dump { my $value; print "Dumping LondConnectionObject:\n"; while(($key, $value) = each %$self) { - print "$key -> $value\n"; + print STDERR "$key -> $value\n"; } print "-------------------------------\n"; } @@ -157,7 +167,7 @@ sub new { PeerPort => $self->{Port}, Type => SOCK_STREAM, Proto => "tcp", - Timeout => 5)) { + Timeout => 3)) { return undef; # Inidicates the socket could not be made. } # @@ -276,7 +286,7 @@ sub Readable { $key=substr($key,0,32); my $cipherkey=pack("H32",$key); $self->{Cipher} = new IDEA $cipherkey; - if($self->{Cipher} == undef) { + if($self->{Cipher} eq undef) { $self->Transition("Disconnected"); $socket->close(); return -1;