trivial v0.1.0 Trivial.Daemon View Source
UDP Daemon for the TFTP protocol. Listens on a port for "accept"-style UDP connections, then spawns a server to handle the continued processing of the results.
You should use this module directly to start up a TFTP service if you don't necessarily want a supervision tree, for example, in tests. The daemon and server processes, will still be linked, so an error will bring down the entire Daemon instance.
Example
The following code starts up a TFTP service on a free udp port and retrieves the udp port so that you can run tests against the functionality of MyModule:
{:ok, daemon} = Trivial.Daemon.start_link(MyModule, initial_value, port: 0)
dest_port = Trivial.Daemon.port(daemon)
If you are testing components with Mox
, be sure to link the
daemon process to your test process with specific allowances.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
a query to find out the UDP port which the daemon is listening to. Mostly useful for testing.
starts a daemon.
Link to this section Functions
child_spec(init_arg) View Source
Returns a specification to start this module under a supervisor.
See Supervisor
.
port(daemon) View Source
a query to find out the UDP port which the daemon is listening to. Mostly useful for testing.
start_link(server_mod, server_init, opts)
View Source
start_link(module(), term(), keyword()) :: GenServer.on_start()
start_link(module(), term(), keyword()) :: GenServer.on_start()
starts a daemon.
Options:
port
: UDP port to open for transactions. Note that a value of 0 will select a random, available port. You may then discover this port by callingport/1
. On some systems, you may be restricted to ports above 1024; as the default TFTP port is 69, an empty value will not automatically be usable in the standard fashion. SeeTrivial
for deployment strategies.Defaults to UDP port 6969