Module: fathom/socket/broadcast

This component provides functions for sending and receiving broadcast messages using UDP over IPv4.
Source:

Methods

(static) close(callback)

This function closes a broadcast socket.
Parameters:
Name Type Description
callback function The callback Fathom invokes once the operation completes. On error, its only argument is a dictionary whose member "error" describes the problem that occurred.
Source:

(static) openReceiveSocket(callback, port)

This function opens a broadcast socket and binds it to the given port.
Parameters:
Name Type Description
callback function The callback Fathom invokes once the operation completes. If successful, its only argument is a numerical socket ID. On error, its only argument is a dictionary whose member "error" describes the problem that occurred.
port integer The local port on which the socket will listen for broadcast messages.
Source:

(static) openSendSocket(callback)

This function opens a socket suitable for transmitting broadcast messages.
Parameters:
Name Type Description
callback function The callback Fathom invokes once the operation completes. If successful, its only argument is a numerical socket ID. On error, its only argument is a dictionary whose member "error" describes the problem that occurred.
Source:

(static) recvFrom(callback, socketid, asstring, timeout, size)

On a socket created via openReceiveSocket(), this function receives data.
Parameters:
Name Type Description
callback function The callback Fathom invokes once the operation completes. If successful, its only argument is a string containing the received message. On error, its only argument is a dictionary whose member "error" describes the problem that occurred.
socketid integer The socket handle previously obtained from one of the opening functions.
asstring boolean Return the bytes as string (default false).
timeout integer Time to wait for the data (in ms), < 0 waits forever, 0 no wait (default).
size integer Number of bytes to read (or 0 to ignore - default).
Source:

(static) sendTo(callback, socketid, msg, ip, port)

This function transmits data on a broadcast socket.
Parameters:
Name Type Description
callback function The callback Fathom invokes once the operation completes. On error, its only argument is a dictionary whose member "error" describes the problem that occurred.
socketid integer The socket handle previously obtained from one of the opening functions.
msg string The message to transmit.
ip string The broadcast IPv4 address to send to.
port integer The (UDP) port to send to.
Source: