I chopped down your code quite a bit, and also created a multi-threading server. I tried with 100 socket, and don’t see any problem.

Failed to go 200, the problem is low virtual memory, any way, the code itself works.

server.pl: use IO::Socket::INET; use threads; use strict; my $server = new IO::Socket::INET(Proto => "tcp", LocalPort => 7001, L +isten => 5) || die "failed to establish socket\n"; while (1) { my $client = $server->accept; threads->create(\&client_handle, $client); } sub client_handle { my $client = shift; while (1) { my $line = <$client>; chomp $line; print $client $line + 1, "\n"; } } client.pl: use strict; use IO::Socket; use threads; use threads::shared; my $numClients = shift; my %thread_status : shared; my $server_status : shared = 'threading'; $| = 1; print "Creating $numClients clients\n"; for (my $i=0; $i<$numClients; $i++) { my $socket = IO::Socket::INET->new(Proto => "tcp", PeerAddr => "lo +calhost", PeerPort => 7001) || print "Socket creation error: $!\n"; threads->new(\&handle_client,$socket,$i)->detach; print "."; } print "\nAll Created\n"; sleep 1; $server_status = 'ready'; <STDIN>; #<------------------------------------------------------------ handle_ +client --> sub handle_client { my ($socket,$clientNum) = @_; while ($server_status eq 'threading') { sleep 1 } print $socket "1\n"; while (1) { my $line = <$socket>; chomp $line; print "$clientNum <<== $line\n"; print $socket $line + 1, "\n"; sleep 1; } return; }

In reply to Re: Re: Re: thread failed to start? by pg
in thread thread failed to start? by noslenj123

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.