Fathom v0.2

component fathom.socket.multicast

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

Methods

Methods Returns Description
closeSocket( callback ) void static This function closes a multicast 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, ip, port ) void static This function opens a multicast socket and binds it to the given IP address and 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.
  • ip <string> The IPv4 address of the multicast group to join.
  • port <integer> The local port on which the socket will listen for multicast messages.
openSendSocket( callback, ttl ) void static This function opens a socket suitable for transmitting multicast messages.

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.
  • ttl <integer> The multicast TTL, i.e., the number of hops the datagram can traverse, doubling as the multicast "threshold" of host/network/site/etc.
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.
receiveDetails( callback, socketid ) void static Like receive(), but upon success the callback receives dictionary with the following key/val structure: "text" contains the received data, "peer" is another dictionary with members "ip" for the sender's IPv4 address and "port" for the sender's port.

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 an associative array 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 via UDP on a multicast socket.
This function should report the number of bytes successfully transmitted to the callback. The underlying implementation should do better error handling.

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 IPv4 address of the multicast group to send to.
  • port <integer> The (UDP) port to send to.