LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-08-2004, 12:11 AM   #1
hitesh29
LQ Newbie
 
Registered: Apr 2004
Posts: 2

Rep: Reputation: 0
problem using socket in perl for linux enviornment


i have problem regarding data tranfer using linux .

i want to transfer file from one linux machine to another

my code for client that send data to server is

#!/usr/bin/perl

use IO::Socket;
$sock = new IO::Socket::INET (PeerAddr => '172.16.40.11',
PeerPort => 50010,
Proto => 'tcp'
);
die "Socket could not be created. Reason: $!\n" unless $sock;
print "enter the filename:";
my $name = <STDIN>;
open(IN,"$name") || die "can't open i/p file";
while(<IN>){
print $sock $_;

print $_;
}
close (IN);
close ($sock);


and the code for the server is:


#!/usr/bin/perl

use IO::Socket;

$sock = new IO::Socket::INET (LocalHost => '172.16.40.11',
LocalPort => 50010,
Proto => 'tcp',
Listen => 10,
);
die "Socket could not be created. Reason: $!" unless $sock;
my $file ="/home/temp/archivefile";


open(SAVAN,">".$file);

chmod(0777,"$file");

while ($new_sock = $sock->accept()) {
while (defined ($buf = <$new_sock>)) {

print SAVAN $buf || die("$!");
print $buf || die();


}
}
close ($sock);
close(SAVAN);


my problem is that i have been successful in data transfer but i can not writ e data in file that is specified by variable $file .
but i m able to write contents of the file that i transfer from machine 172.16.40.1 to machine 172.16.40.11 on STDOUT of machine 172.16.40.11.

how can i write transfered data into file on server 172.16.40.11?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Raw socket with perl Whiteghost Linux - General 1 10-14-2005 10:29 AM
perl - IO::Socket::INET - for (;;) statement?? AM1SHFURN1TURE Programming 3 03-29-2005 10:55 PM
100% linux enviornment in the corporate world admstng Linux - Enterprise 1 01-04-2005 08:16 AM
problem with writing into a file using socket(perl) akaash Programming 3 04-08-2004 06:06 AM
use IO::Socket help (perl) vexer Programming 0 03-06-2003 08:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration