Fathom v0.2

component fathom.socket.broadcast

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

Methods

Methods Returns Description
closeSocket( callback ) void static This function closes a broadcast socket.

Parameters:

  • 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.
openReceiveSocket( callback, port ) void static This function opens a broadcast socket and binds it to the given port.

Parameters:

  • 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.
openSendSocket( callback ) void static This function opens a socket suitable for transmitting broadcast messages.

Parameters:

  • 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.
receive( callback, socketid ) void static On a socket created via openReceiveSocket(), this function receives data.

Parameters:

  • 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.
send( callback, socketid, msg, ip, port ) void static This function transmits data on a broadcast socket.
This function should report the number of bytes successfully transmitted to the callback.

Parameters:

  • 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.