UdpServer
A localhost voice UDP server: it answers IP discovery, echoes keepalives and records every RTP packet for the test
to assert on. new binds it to 127.0.0.1 with an ephemeral port and starts a receive loop that yields to the
scheduler while it waits for a packet.
Summary
Properties
UdpServer.socket :: NetworkSocket?UdpServer.port :: numberUdpServer.packets :: { buffer }UdpServer.clientAddress :: string?UdpServer.clientPort :: number?UdpServer.receiving :: booleanUdpServer.errors :: { string }UdpServer.ignoreDiscovery :: numberUdpServer.onStop :: function?UdpServer.sendingThread :: thread?UdpServer.waitingSends :: { thread }Properties
Section titled “Properties”socket
Section titled “socket”The Zune UDP socket, nil after the server stops.
The ephemeral port the server bound to on 127.0.0.1.
packets
Section titled “packets”Every RTP packet the server received, oldest first. IP discovery requests and keepalives are not recorded.
clientAddress
Section titled “clientAddress”The address the latest packet came from, nil before the first packet.
clientPort
Section titled “clientPort”The port the latest packet came from, nil before the first packet.
receiving
Section titled “receiving”True while the receive loop runs; false once stop has ended it.
errors
Section titled “errors”Every error the receive loop raised, other than the cancelled receive that stop causes and Windows' report of a
client that has gone.
ignoreDiscovery
Section titled “ignoreDiscovery”How many of the next IP discovery requests to drop without a reply.
onStop
Section titled “onStop”Called with the handle after it stops.
sendingThread
Section titled “sendingThread”The thread whose send has the socket, nil while no send is in flight.
waitingSends
Section titled “waitingSends”Threads waiting for their turn to send, oldest first.
Methods
Section titled “Methods”UdpServer : send ( packet ) -> ()
Sends one packet to the client the latest packet came from, after any send already in flight. Errors before any client has sent a packet or after the server stops.
Parameters
| packet: buffer |
UdpServer : stop ( ) -> ()
Closes the socket, which cancels the pending receive and ends the receive loop, and wakes every send waiting for its turn so it fails on the closed socket. Safe to call twice.
Functions
Section titled “Functions”UdpServer . new ( settings ) -> UdpServer
Binds a UDP socket on 127.0.0.1 with an ephemeral port and starts the receive loop.
Parameters
| settings: { { onStop: ((server: UdpServer) -> ())? } } |
Returns
| UdpServer |