TFTP(3pm)
π Net::TFTP β the TFTP Client class, bestie edition π
okay so welcome to Net::TFTP, a whole Perl module living in the TFTP(3pm) slot of your manual, from the User Contributed Perl Documentation corner of the world. it's the TFTP client class. yes THE one. we're doing file transfers and we're doing them cute. π
β¨ NAME β¨
Net::TFTP β TFTP Client class, she's a whole vibe π
πΈ SYNOPSIS πΈ
like, here's the entire flex in one go, no cap:
use Net::TFTP;
$tftp = Net::TFTP->new("some.host.name", BlockSize => 1024);
$tftp->ascii;
$tftp->get("remotefile", "localfile");
$tftp->get("remotefile", \*STDOUT);
$fh = $tftp->get("remotefile");
$tftp->binary;
$tftp->put("localfile", "remotefile");
$tftp->put(\*STDOUT, "remotefile");
$fh = $tftp->put("remotefile");
$err = $tftp->error
look at her. iconic behavior fr fr. π
π¦ DESCRIPTION π¦
so Net::TFTP is a class implementing a simple Trivial File Transfer Protocol client in Perl, exactly as described in RFC1350. periodt.
and because she's generous, Net::TFTP also supports the TFTP Option Extension (as described in RFC2347), with the following options:
- RFC2348 Blocksize Option β¨
that's it, that's the list, that's the whole glow-up.
π CONSTRUCTOR π
new ( [ HOST ] [, OPTIONS ])
okay so this creates a new Net::TFTP object, bestie. here's the deal:
- HOST = the default host to connect to
- OPTIONS = the default transfer options
and the valid options are giving:
Timeoutβ Timeout in seconds before retry β default:5Retriesβ Maximum number of retries β default:5Portβ Port to send data to β default:69Modeβ Mode to transfer data in,"octet"or"netascii"β default:"netascii"BlockSizeβ Negotiate size of blocks to use in the transfer β default:512IpModeβ Indicates whether to operate in IPv6 mode β default:"v4"
memorize these. they're your defaults. they're the blueprint. π
π METHODS π
get ( REMOTE_FILE [, LOCAL ] [, OPTIONS ])
get REMOTE_FILE from the server, slay. π
the OPTIONS can be any that are accepted by new, plus the following:
Hostβ Override default host
now listen, this part matters:
if the LOCAL option is missing, the get will return a filehandle. and this filehandle must be read ASAP because the server will otherwise timeout. like, do not ghost it. it will leave you on read and you will lose data. π
if the LOCAL option is given, then it can be a file name or a reference. if it is a reference, it is assumed to be a reference that is valid as a filehandle. get will return true if the transfer is successful and undef otherwise.
valid filehandles are:
- A sub-class of
IO::Handle - A tied filehandle
- A GLOB reference (eg
"\*STDOUT")
those are the three. the holy trinity. π«Ά
put ( [ LOCAL, ] REMOTE_FILE [, OPTIONS])
put a file to the server as REMOTE_FILE, we're uploading bestie, no big deal. β¨
the OPTIONS can be any that are accepted by new, plus the following:
Hostβ Override default host
if the LOCAL option is missing, the put will return a filehandle. and this filehandle must be written to ASAP because the server will otherwise timeout. same energy as get β do not delay, do not pass go.
if the LOCAL option is given, then it can be a file name or a reference. if it is a reference, it is assumed to be a valid filehandle as described above. put will return true if the transfer is successful and undef otherwise.
error
if there was an error, then this method will return an error string. that's it. she tells you what went wrong. π
host ( [ HOST ] )
timeout ( [ TIMEOUT ] )
port ( [ PORT ] )
mode ( [ MODE ] )
retries ( [ VALUE ] )
block_size ( [ VALUE ] )
debug ( [ VALUE ] )
set or get the values for the various options. here's how it works:
- if an argument is passed, then a new value is set for that option and the previous value is returned
- if no value is passed, then the current value is returned
so she's a getter AND a setter. dual threat. main character energy, honestly. π
ip_mode ( [ VALUE ] )
set or get which verion of IP to use ("v4" or "v6").
ok yes the original says "verion" and I am NOT fixing it, that's the canon, we preserve the canon, no cap. π«Ά
ascii
netascii
set the transfer mode to "netascii".
binary
octet
set the transfer mode to "octet".
π AUTHOR π
Graham Barr <gbarr@pobox.com> β shoutout to the actual legend who wrote this. π
π COPYRIGHT π
Copyright (c) 1998,2007 Graham Barr. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
okay bestie that's the whole page, you're officially fluent in Net::TFTP, go transfer some files responsibly. π¦β¨
and a lil sign-off just for you: this page came from perl v5.36.0, dated 2022-10-13, and it lives under TFTP(3pm). stay iconic, read your RFCs, hydrate. πππ
π¦ where this page comes from
- ubuntu noble: libnet-tftp-perl 0.1901-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-tftp-perl 0.1901-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-tftp-perl 0.1901-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms