Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel
borderColor#3D3D3D
bgColor#F4F4F4
titleColor#3D3D3D
borderWidth0
titleBGColor#3D3D3D
borderStylesolid

ON THIS PAGE

Table of Contents
indent20px

For more information about available methods, refer to the roDatagramReceiver and roDatagramEvent entries.

Methods

boolean BindLocalPort(in long port)

long GetLocalPort()

boolean JoinMulticastGroup(in DOMString group)

boolean SendTo(in DOMString dest, in long port, in ArrayBufferView data)

boolean SendTo(in DOMString dest, in long port, in DOMString data)

void Close()

Shuts down the instance, preventing it from further consuming resources. If this method is not called, garbage collection determines when the instance will be destroyed.

Events

The following event is available on the BSDatagramSocket object. It can receive an event of the type DatagramSocketEvent. Use GetBytesgetBytes() to retrieve the body of the UDP message.

ondatagram

DatagramSocketEvent

The DatagramSocketEvent has the following attributes:

readonly

...

attribute

...

DOMString

...

remoteHost

readonly

...

attribute

...

int

...

remotePort

...

 

The DatagramSocketEvent supports the following methods:

ArrayBuffer

...

getBytes()

Example

See here to learn how to convert between strings and an ArrayBuffer.

Code Block
languagejs
var bsSocketMessage = new BSDatagramSocket();
bsSocketMessage.BindLocalPort(1234)
bsSocketMessage.ondatagram = function(e){

  var txtDec = new TextDecoder("utf-8");
  console.log("Received " + txtDec.decode(e.getBytes()));
};