List, >From the TCP client with IO::Socket on the perlipc page I have made the following:
# Server code use strict; use warnings; use IO::Socket; use Net::hostent; use Sys::Hostname 'hostname'; $|++; my $Port = 1971; my $Host = hostname(); my $Server = IO::Socket::INET->new(Proto => 'tcp', LocalPort => $Port, Listen => SOMAXCONN, Reuse => 1); die "Can't setup Server" unless $Server; print "[Server $Host accepting Clients]\n"; while(my $Client = $Server->accept()) { $Client->autoflush(1); print $Client "Connected to $Host\n"; my $HostInfo = gethostbyaddr($Client->peeraddr); printf "[Connect from %s]\n", $HostInfo->name || $Client->peerhost; while(<$Client>) { print $Client `$_` if /^dir/i; print $_; last; } close $Client; } ###################################################################### # Client code #!/usr/local/bin/nsPerl5.005_03/nsperl -w use strict; use IO::Socket; my ($KidPID, $Line); my $Port = '1971'; my $Host = '123.123.123.123'; my $Handle = IO::Socket::INET->new(Proto => 'tcp', PeerAddr => $Host, PeerPort => $Port) or die "Cant connect to $Host on $Port:- $!"; $Handle->autoflush(1); die "Cant fork: $!" unless defined($KidPID = fork()); if($KidPID) { while(defined($Line = <$Handle>)) { print STDOUT $Line; } kill("TERM", $KidPID); } else { print $Handle 'dir d:'; #while(defined($Line = <STDIN>)) #{ # print $Handle $Line; #} } I can get connectivity between the two machines, and with the while uncommented on the client I can key in "dir d:" and a get a response from the server. However what I really need is code that fires off a command from the client with arguments (without keying it in from STDIN), which can then be picked up by the server, processed and then returned to the client, closing the client/connection after the return of data, rather than the continuous interactive example that I borrowed this code from. I guess the else in my client is the show stopper because my xterm just sits there. And when I control C the xterm client the server flushes out the "dir d:" string to the terminal. So I further guess that I need to close/kill one of the processes that fork spawns in order for it to return, but I'm not sure how. Any help appreciated, thanks. Just in P.S./ The client sits on a Solaris machine (Perl 5.5 binary dist), while my server is on Win2003 server (AS 5.6). _______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs