Above is the client code that writes/reads from a socket. Usage: ./client, and then input through STDIN to write to the socket. Is there a way I can pass $ARGV[0] in the child process like: print $socket $ARGV[0] ?use IO::Socket::INET; my $socket = IO::Socket::INET->new( PeerAddr => 'localhost', PeerPort => '9000', Proto => 'tcp', Type => SOCK_STREAM ) or die "Error: cant create listening socket: $!\n"; $socket->autoflush(1); # so output gets there right away die "can't fork: $!" unless defined( $kidpid = fork() ); #parent process if ($kidpid) { while ( defined( my $line = <$socket> ) ) { print STDOUT $line; } kill( "TERM", $kidpid ); # send SIGTERM to child } #the child process else { my $line = <STDIN>; while ( defined($line) ) { print $socket $line; } } close($socket);
In reply to pass ARGV to STDIN by icylisper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |