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"; } }

In reply to Re: ChatServer by zentara
in thread ChatServer by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.