Hello! any help and tips on better code would be appreciated :), my question spawns from the code below... It works just how I would like it to on Windows 7, and also on Backtrack (without the system commands and win32 module ofc). However my server just wont seem to work on Windows XP for some reason, as far as I know it opens the socket successfully. When my client ( on another computer ) attempts to send a message that the server should get, my client says it can not connect. I have tried using different ports and such to no avail. I should note I am new to network programming alltogeather; Thank you! (CLIENT code below server)

system("color 07"); use Win32::Console; my $CONSOLE = Win32::Console->new(STD_OUTPUT_HANDLE); my $attr = $CONSOLE->Attr(); # Get current console colors use IO::Socket; $| = 1; ########################################################### $socket = new IO::Socket::INET ( LocalPort => '4444', Proto => 'tcp', Listen => 1, Reuse => 1 ); die "Coudn't open socket" unless $socket; while(1){ if($client = $socket->accept()){ while(<$client>){ chomp; my $line = $_; my @chars = split(//,$line); foreach(@chars){ if($_ eq '[' || $_ eq ']'){ $CONSOLE->Attr($FG_LIGHTRED); print $_; $CONSOLE->Attr($attr); } elsif($_ eq '{' || $_ eq '}'){ $CONSOLE->Attr($FG_MAGENTA); print $_; $CONSOLE->Attr($attr); } else{ print $_; } } print "\n"; } } }
And this is the subroutine I call in another program on another computer:
sub global_send($){ my $data = $_[0]; foreach my $ip(@connected_ips){ my $server = new IO::Socket::INET ( PeerAddr => $ip, PeerPort => 4444, Proto => 'tcp', ) or warn "Can not connect to client: $ip\nSysErr: $!\n"; if(!defined($server)){return;} $server->send($data); $server->close(); } }

In reply to server with IO::Socket::INET by Rudolf

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.