Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(helpers) document udp server return values #6077

Merged
merged 1 commit into from Jul 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 11 additions & 4 deletions spec/helpers.lua
Expand Up @@ -1095,11 +1095,17 @@ end


--- Starts a local UDP server.
-- Accepts a single connection, reading once and then closes
-- Reads the specified number of packets and then closes.
-- The server-thread return values depend on `n`:
--
-- * `n = 1`; returns the received packet (string), or `nil + err`
--
-- * `n > 1`; returns `data + err`, where `data` will always be a table with the
-- received packets. So `err` must explicitly be checked for errors.
-- @name udp_server
-- @param `port` The port the server will be listening on
-- @param `n` The number of packets that will be read
-- @param `timeout` Timeout per read
-- @param `port` The port the server will be listening on (default `MOCK_UPSTREAM_PORT`)
-- @param `n` The number of packets that will be read (default 1)
-- @param `timeout` Timeout per read (default 360)
-- @return A thread object (from the `llthreads2` Lua package)
local function udp_server(port, n, timeout)
local threads = require "llthreads2.ex"
Expand Down Expand Up @@ -1129,6 +1135,7 @@ local function udp_server(port, n, timeout)
else
i = i + 1
data[i] = pkt
err = nil -- upon succes it would contain the remote ip address
end
end
server:close()
Expand Down