The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


TFTP - TFTP Client class


    use TFTP;

    $tftp = new TFTP("");


TFTP is a class implementing a simple TFTP client in Perl as described in RFC783.


TFTP stands for Trivial File Transfer Protocol.



This is the constructor for a new TFTP object. HOST is the name of the remote host to which a TFTP connection is required.

OPTIONS are passed in a hash like fashion, using key and value pairs. Possible options are:

Port - The port number to connect to on the remote machine for the TFTP connection

Mode - Set the transfer mode [NETASCII, OCTET] (defaults to NETASCII)

Timeout - Set the timeout value before retry (defaults to 2 sec)

MaxTimeout - Set the maximum timeout value before retry (defaults to 8 sec)

Retries - Set the number of retries (defaults to 3 with arithmetic backoff)


mode (TYPE)

This method will set the mode to be used with the remote TFTP server to specify the type of data transfer. The return value is the previous value.

netascii, ascii, octet, binary

Synonyms for mode with the first argument set accordingly


Get REMOTE_FILE from the server and store locally. LOCAL_FILE may be a filename or a filehandle. If not specified the the file will be stored in the current directory with the same leafname as the remote file.

Returns LOCAL_FILE, or the generated local file name if LOCAL_FILE is not given.


Put a file on the remote server. LOCAL_FILE may be a name or a filehandle. If LOCAL_FILE is a filehandle then REMOTE_FILE must be specified. If REMOTE_FILE is not specified then the file will be stored in the current directory with the same leafname as LOCAL_FILE.

Returns REMOTE_FILE, or the generated remote filename if REMOTE_FILE is not given.


Close the current socket and release any resources. A more complete way to release resources is to call 'undef $tftp;' on the session object.


When reporting bugs/problems please include as much information as possible. It may be difficult for me to reproduce the problem as almost every setup is different.

A small script which yields the problem will probably be of help. It would also be useful if this script was run with the extra options debug = 1> passed to the constructor, and the output sent with the bug report. If you cannot include a small script then please include a Debug trace from a run of your program which does yield the problem.


G. S. Marzot <>


tftp(1), tftpd(8), RFC 783

Copyright (c) 1998 G. S. Marzot. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.