in reply to Re: FIle transfer using sockets
in thread FIle transfer using sockets

In order to read file name you should use $file1=<$conn>.

Only if
print $sock "$file";
is changed to
print $sock "$file\n";

Replies are listed 'Best First'.
Re^3: FIle transfer using sockets
by zwon (Abbot) on May 10, 2009 at 08:15 UTC

    You're right. I suggest something like this for client side:

    print $sock "$file\0";
    and something like this for server:
    { local $/ = "\0"; $file1 = <$conn>; chomp $file1; }

    "\n" isn't portable. And at least on *nix file name may contain "\n"

      You might find Internet Line Terminators interesting. Not that what you recommend wouldn't work, but there might be some value in being consistent with many of the existing protocols.