Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
oh ya the chkAns sub is just a check sum for the request....sub Sserv { my ($sever, $log, $logfile) = @_; $server = IO::Socket::INET->new( LocalPort => 3300, Type => SOCK_STREAM, Listen => 0, Reuse => 1, ) or die $!; open($log, ">> $logfile"); select((select($log), $| = 1)[0]); while (my $conn = $server->accept) { my $t = threads->create("gClnt", $conn, $log, $server) or die +$!; $t->detach; } } sub gClnt { my ($conn, $log, $server) = @_; my $user; while (defined(my $ans = <$conn>)) { if (my $mess = chkAns($ans)) { if ($mess =~ /^LOGIN_REQ:.*/) { if ($user = userLogin($mess)) { print $conn "GOOD"; } else { print $conn "BAD"; } } if ($user) { print "$user:$mess\n"; KILLER($conn, $log, $server) if $mess =~ /^END_PROC_RE +Q:.*/; last if $mess =~ /^LOGOUT_REQ:.*/; } else { last; } } } } sub userLogin { my ($mess) = @_; if ($mess =~ m/^LOGIN_REQ:([\d \w]+):([\d \w]+)/) { tie(my %db, 'SDBM_File', $userDB, O_RDWR|O_CREAT, 0666) or die + "Problem accessing user DB\n"; if (my $pass = $db{$1}) { my $pwd = PwdCrypt->new($2); if ($pwd->check($pass)) { return $1; } } untie %db; } return undef; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Socket problems?????
by Thelonius (Priest) on Apr 29, 2003 at 20:09 UTC | |
by Anonymous Monk on Apr 29, 2003 at 21:51 UTC |