There are two things you need your client to tell your server: the file's name and the file's contents. Part of the contents is knowing when the file ends, so either you have to send a length at the beginning, some kind of EOF marker at the end, or else close the connection at EOF.
A simple protocol would be:
> SENDFILE <size> name<eol> < OK > (file contents, exactly <size> bytes) < OKAssuming you have the file name and size in variables already, this could be as simple as:
print SOCK "SENDFILE $filesize $filename\r\n"; $resp = <SOCK>; if ($resp !~ /^OK/) { die "Bad response\n" } while(read(INFILE,$_,8192)) { print SOCK; } $resp = <SOCK>; if ($resp !~ /^OK/) { die "Bad response\n" }
In reply to Re: Copying files using a specific port
by sgifford
in thread Copying files using a specific port
by rupesh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |