ashok13123 has asked for the wisdom of the Perl Monks concerning the following question:
Server SideCLIENT.pl #!/usr/bin/perl use strict; use IO::Socket; $file="file1.txt" #This is the file to be opened in server side my $sock = new IO::Socket::INET( PeerAddr => '192.168.100.30', PeerPort => 7880, Proto => 'tcp', ); print $sock "$file"; open(FILE,">file.txt"); binmode(FILE); while(<$sock>) { print FILE $_; print FILE <$sock>; } close(FILE);
My intention is to send a file name to a remote server from client and the server should open the file and send the contents to client.The client should write it tio a local file My problem is that the server is not receiving the filename send by client.How can i receive the file name and send the contents???#!/usr/bin/perl use strict; use IO::Socket; my $file1; my $sock = new IO::Socket::INET( LocalAddr => '192.168.100.30', LocalPort => 6224, Listen => 10, Proto => 'tcp', Reuse => 1, ); while(my $conn = $sock->accept()) { $file1=$_;#This should collect the filename send by client right? open(FILE,"$file1"); binmode(FILE); my @file = <FILE>; close(FILE); foreach my $x (@file) { print $conn $x; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: FIle transfer using sockets
by ikegami (Patriarch) on May 09, 2009 at 06:34 UTC | |
|
Re: FIle transfer using sockets
by zwon (Abbot) on May 09, 2009 at 09:53 UTC | |
by ikegami (Patriarch) on May 10, 2009 at 04:25 UTC | |
by zwon (Abbot) on May 10, 2009 at 08:15 UTC | |
by ig (Vicar) on May 10, 2009 at 09:45 UTC |