Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 04-08-2004, 12:11 AM   #1
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


use IO::Socket;
$sock = new IO::Socket::INET (PeerAddr => '',
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";
print $sock $_;

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

and the code for the server is:


use IO::Socket;

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



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

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

close ($sock);

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 to machine on STDOUT of machine

how can i write transfered data into file on server


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:34 AM.

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