dnsjit.output.tcpcli(3)

πŸ“¦
version 1.5.1 Β· 5 versions
, in epel 10, epel 9, fedora 43, fedora 44, ubuntu resolute, ubuntu stonking

πŸ’– dnsjit.output.tcpcli β€” the manual page, but make it cute πŸ’–

okay bestie, so you know how sometimes you just need a simple, length aware, TCP client and you don't want drama? that's literally this. it lives in dnsjit.output.tcpcli(3), in the Library Functions Manual, and it's giving "I handle your payloads so you don't have to" πŸ’…


✨ SYNOPSIS ✨

local output = require("dnsjit.output.tcpcli").new("127.0.0.1", "53")

like. one line. that's the whole vibe. slay. πŸŽ€


🌸 DESCRIPTION 🌸

so basically: it's a simple TCP client that takes any payload you hand it, sends the length of that payload as an unsigned 16 bit integer, and then sends the payload itself. length-first, content-second. she's organized like that. ✨

when receiving, she's gonna do the same thing but backwards: first she retrieves the length of the payload as an unsigned 16 bit integer, and she will stall until she gets it β€” even if nonblocking mode is on. no cap, she waits. periodt. πŸ’€

then she retrieves at least that amount of bytes. and here's the tea:

  • if nonblocking mode is used at this point, she'll return a payload object with length zero if there was nothing to receive, or if the full payload hasn't been received yet.
  • additional calls will continue retrieving the payload. she picks up where she left off, main character energy. πŸ‘‘

πŸ¦‹ Attributes πŸ¦‹

  • timeout β€” a core.timespec that is used when producing objects. her little clock. ⏰

🧚 Functions 🧚

  • Tcpcli.new() β€” create a new Tcpcli output. fresh out the box, brand new, iconic. 🫢
  • Tcpcli:timeout(seconds, nanoseconds) β€” set the timeout when producing objects.
  • Tcpcli:connect(host, port) β€” connect to the host and port, and return 0 if it worked. success!! πŸŽ‰
  • Tcpcli:nonblocking(bool) β€” enable (true) or disable (false) nonblocking mode, and return 0 if it worked. and if bool isn't specified at all? then she just returns whether nonblocking mode is on (true) or off (false). a lil check-in, iykyk. πŸ‘€
  • Tcpcli:receive() β€” return the C functions and context for receiving objects. these objects will be sent.
  • Tcpcli:produce() β€” return the C functions and context for producing objects. these objects are received. okay so here's the whole situation:
    • if nonblocking mode is enabled, the producer will return a payload object with length zero if there was nothing to receive, or if the full payload hasn't been received yet.
    • if nonblocking mode is disabled, the producer will wait for data, and if it times out (see timeout) it will return a payload object with length zero.
    • if a timeout happens during the first stage β€” getting the length β€” it will fail and return nil. 😭
    • additional calls will continue retrieving the payload.
    • and the producer returns nil on error. that's the rule. πŸ’€
  • Tcpcli:packets() β€” return the number of "packets" sent. and yes, the quotes are doing heavy lifting: it's actually the number of completely sent payloads. πŸ™ˆ
  • Tcpcli:received() β€” return the number of "packets" received. again, actually the number of completely received DNS messages. not me being pedantic, it's literally in the docs. πŸ’…
  • Tcpcli:errors() β€” return the number of errors when sending. we don't talk about those. πŸ’€

πŸ‘‘ AUTHORS and CONTRIBUTORS πŸ‘‘

the legends themselves:

  • Jerry LundstrΓΆm (DNS-OARC)
  • TomΓ‘Ε‘ KΕ™Γ­ΕΎek (CZ.NIC)
  • Petr Ε paček (ISC)

maintained by DNS-OARC

https://www.dns-oarc.net/

πŸ“ BUGS πŸ“

got issues? got feature requests? bestie, take it here:

https://codeberg.org/DNS-OARC/dnsjit/issues

got questions? need help? hit up:

admin@dns-oarc.net
don't be shy, they're nice. fr fr. 🌈

and that's the whole page, babe πŸ’– this was dnsjit version 1.5.1, documented as dnsjit.output.tcpcli(3) β€” go forth and send some length-prefixed payloads, you absolute icon. ⭐ πŸ¦‹ πŸ’œ