in reply to ChatServer

Hi again, I'm glad the holidays are over...can get back to clear thinking. :-)

This is starting to look pretty good from my testing. I like the -cev features. It seems to work without crashing, but I still see some kind of weird thread leakage. It isn't real bad, but somehow I don't like seeing "stray unused threads" in my ps list.

This is what I did to test.

I setup 3 clients, and started the server. Then I would kill off the clients in the reverse order of starting them up(3-2-1). Then I would check the output of socklist and ps auxww. I would repeat about 5 times without restarting the server. Sometimes I would get 3 extra threads in my ps list, even if all clients were killed. What is even more perplexing, is that if I occaisionally would kill off the clients in creation order(1-2-3), it would sometimes cleanup the stray threads and the socklist.

This is starting to work real nice otherwise, I couldn't crash the server.

One other minor thing, I had to add 192.168.0.0 to the allowed servers.

if ( $pAddr !~ /^127\.0\.0\./ && $pAddr !~ /^10\.10\.10\.\d+/ && $pAddr !~ /^192\.168\.0\.\d+/ )

In case it makes some difference, here is the client I'm using to test.

#!/usr/bin/perl -w use strict; use IO::Socket; my ( $host, $port, $kidpid, $handle, $line ); ( $host, $port ) = ('192.168.0.1',3333); #this is for identifying chat if desired #my $name = shift || ''; #if($name eq ''){print "What's your name?\n"} #chomp ($name = <>); # create a tcp connection to the specified host and port $handle = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => $port ) or die "can't connect to port $port on $host: $!"; $handle->autoflush(1); # so output gets there right away print STDERR "[Connected to $host:$port]\n"; # split the program into two processes, identical twins die "can't fork: $!" unless defined( $kidpid = fork() ); # the if{} block runs only in the parent process if ($kidpid) { # copy the socket to standard output while ( defined( $line = <$handle> ) ) { print STDOUT $line; } kill( "TERM", $kidpid ); # send SIGTERM to child } # the else{} block runs only in the child process else { # copy standard input to the socket while ( defined( $line = <STDIN> ) ) { #print $handle "$name->$line"; print $handle "$line"; } }