From IO::Socket::INET docs:

If "Listen" is defined then a listen socket is created, else if the socket type, which is derived from the protocol, is SOCK_STREAM then connect() is called.

You're using a connect() socket only, so your process family won't talk much. You need at least one process listening and the other connecting so they can speak; but please note that it will be a client/server (i.e. child/parent) dialog, so the parent won't be able to say a thing until the child requests. If you need a different kind of dialog, then you should change your path to the IPC route.

Update: This is the classic ping-pong example, that you could find helpful...

#!/usr/bin/perl use IO::Socket::INET; use strict; use warnings; if (my $pid = fork()) { my $listen = IO::Socket::INET->new( LocalAddr => 'localhost', LocalPort => 9000, Proto => 'tcp', Listen => 1, ) or die "Cannot create listening socket: $!\n"; my $client = $listen->accept() or die "Cannot get a connection: $!\n"; $client->autoflush(1); while (defined(my $line = <$client>)) { print "server < $line"; sleep 1; pong($client); } } else { print "waiting for parent to setup...\n"; sleep 1; my $sock = IO::Socket::INET->new( PeerAddr => 'localhost', PeerPort => 9000, Proto => 'tcp', Type => SOCK_STREAM ) or die "Cannot create connecting socket: $!\n"; $sock->autoflush(1); ping($sock); while (defined(my $line = <$sock>)) { print "client < $line"; sleep 1; ping($sock); } } sub ping { my ($fh) = @_; print "client > ping\n"; print {$fh} "ping\n"; } sub pong { my ($fh) = @_; print "server > pong\n"; print {$fh} "pong\n"; }

In reply to Re: pass ARGV to STDIN by alexm
in thread pass ARGV to STDIN by icylisper

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.