in reply to Bidirectional Communication using sockets and forking

if(defined($child_pid)){

You probably meant if($child_pid){, as testing defined $child_pid is true for both parent and child (pid==0), so they'll both execute the same code — which is most likely not what you want...

Replies are listed 'Best First'.
Re^2: Bidirectional Communication using sockets and forking
by Anonymous Monk on Dec 28, 2009 at 12:46 UTC
    That was the first initial thing I tried, at the Server.pl program, it would allow writing at that terminal session but whatever typed in is not conveyed through into the client session, the same thing is true vice versa...
      That was the first initial thing I tried, at the Server.pl program

      Did you have it in Client.pl, too?  With if (defined($child_pid)), the client would never execute its read loop either, i.e.

      while(my $line = <$socket>){ print "SERVER says: $line\n"; }

      With the mentioned change in both Server.pl and Client.pl, your code works fine for me... — except that you may not want to add another empty line every time the server sends a line to the client  (the superfluous "\n" in print $client "$line\n"; ).