Examples — tftp v1.2.2

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" > file.txt

Step 2. Start the TFTP server:

          1> {ok, Pid} = tftp:start([{port, 19999}]).
          {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