I tried the suggestion and still got nothing back.
client code:
#!/usr/bin/env perl use IO::Socket; $remote_port=7071; $remote_host="localhost "; $socket = IO::Socket::INET->new(PeerAddr => $remote_host, PeerPort => $remote_port, Proto => "tcp", Type => SOCK_STREAM) or die "Couldn't connect to $remote_host:$remote_port : $@\n"; $socket->autoflush(1); # ... do something with the socket print $socket "ls:/tmp\n"; while (<$socket>) { print "$_\n"; } # and terminate the connection when we're done close($socket);

Server code:
#!/usr/bin/env perl # perl modules use IO::Socket; use POSIX qw(:sys_wait_h); use Sys::Hostname; use IPC::Open3 qw( open3 ); # get hostname my $hostname = hostname; # Port my $port = "7071"; $SIG{CHLD} = 'IGNORE'; # make socket connection my $socket = new IO::Socket::INET ( LocalHost => "$hostname", LocalPort => "$port", Proto => 'tcp', Reuse => 1, Listen => SOMAXCONN, ); die "Could not create socket: $!\n" unless $socket; # allow server to accept clients while ($client = $socket->accept()) { # flush input $client->autoflush(1); # input from client while (<$client>) { chomp; # read command and put rest in array my ($command,@var2) = split(":", $_); my $cmd; if ($command eq 'ls'){ @cmd = ( 'ls', '-s', '--', @var2 ); } # run command if (@cmd) { open(local *C_STDIN, '<', '/dev/null') + or die; open(local *C_STDIN, '>&', $client) or + die; my $pid = open3('C_STDIN', '>C_STDOUT' +, 'C_STDOUT', @cmd); waitpid($pid, 0); } } # close client close($client); } # close socket so it can reused close($socket);

In reply to Re^2: socket help by Anonymous Monk
in thread socket help 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.