SYNOPSIS

    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

DESCRIPTION

\*(C`Net::TFTP\*(C' is a class implementing a simple Trivial File Transfer Protocol client in Perl as described in \s-1RFC1350\s0. \*(C`Net::TFTP\*(C' also supports the \s-1TFTP\s0 Option Extension (as described in \s-1RFC2347\s0), with the following options

RFC2348 Blocksize Option

CONSTRUCTOR

new ( [ \s-1HOST\s0 ] [, \s-1OPTIONS\s0 ])

Create a new Net::TFTP object where \s-1HOST\s0 is the default host to connect to and \s-1OPTIONS\s0 are the default transfer options. Valid options are Option Description Default ------ ----------- ------- Timeout Timeout in seconds before retry 5 Retries Maximum number of retries 5 Port Port to send data to 69 Mode Mode to transfer data in, "octet" or "netascii" "netascii" BlockSize Negotiate size of blocks to use in the transfer 512 IpMode Indicates whether to operate in IPv6 mode "v4"

METHODS

get ( \s-1REMOTE_FILE\s0 [, \s-1LOCAL\s0 ] [, \s-1OPTIONS\s0 ])

Get \s-1REMOTE_FILE\s0 from the server. \s-1OPTIONS\s0 can be any that are accepted by \*(C`new\*(C' plus the following Host Override default host If the \s-1LOCAL\s0 option is missing the get will return a filehandle. This filehandle must be read \s-1ASAP\s0 as the server will otherwise timeout. If the \s-1LOCAL\s0 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. \*(C`get\*(C' will return true if the transfer is successful and undef otherwise. Valid filehandles are

  • A sub-class of IO::Handle

  • A tied filehandle

  • A \s-1GLOB\s0 reference (eg \*(C`\*STDOUT\*(C')

put ( [ \s-1LOCAL\s0, ] \s-1REMOTE_FILE\s0 [, \s-1OPTIONS\s0])

Put a file to the server as \s-1REMOTE_FILE\s0. \s-1OPTIONS\s0 can be any that are accepted by \*(C`new\*(C' plus the following Host Override default host If the \s-1LOCAL\s0 option is missing the put will return a filehandle. This filehandle must be written to \s-1ASAP\s0 as the server will otherwise timeout. If the \s-1LOCAL\s0 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. \*(C`put\*(C' 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.

host ( [ \s-1HOST\s0 ] )
timeout ( [ \s-1TIMEOUT\s0 ] )
port ( [ \s-1PORT\s0 ] )
mode ( [ \s-1MODE\s0 ] )
retries ( [ \s-1VALUE\s0 ] )
block_size ( [ \s-1VALUE\s0 ] )
debug ( [ \s-1VALUE\s0 ] )

Set or get the values for the various options. If an argument is passed then a new value is set for that option and the previous value returned. If no value is passed then the current value is returned.

ip_mode ( [ \s-1VALUE\s0 ] )

Set or get which verion of \s-1IP\s0 to use (\*(L"v4\*(R" or \*(L"v6\*(R")

ascii
netascii

Set the transfer mode to "netascii"

binary
octet

Set the transfer mode to "octet"

AUTHOR

Graham Barr <[email protected]>

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.