Search documentation of tftp

# Examples

View Source

The start/1 function starts a daemon process listening for UDP packets on a port. When it receives a request for read or write, it spawns a temporary server process handling the transfer.

This is a simple example of starting the TFTP server and reading the content of a sample file using the TFTP client.

Step 1. Create a sample file to be used for the transfer:

          $ echo "Erlang/OTP 21" > /tmp/file.txt

Step 2. Start the TFTP server:

          1> Callback = {callback,{"",tftp_file,[{root_dir,"/tmp"}]}}.
          2> {ok, Pid} = tftp:start([{port, 19999}, Callback]).
          {ok,<0.65.0>}

Step 3. Start the TFTP client (in another shell):

          1> tftp:read_file("file.txt", binary, [{port, 19999}]).
          {ok,<<"Erlang/OTP 21\n">>}

← Previous Page Overview