BSDatagramSocket
3 min
for more information about available methods, refer to the rodatagramreceiver and rodatagramevent entries methods bindlocalport(in long port) boolean getlocalport() long 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) boolean close() void 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 getbytes() to retrieve the body of the udp message ondatagram datagramsocketevent the datagramsocketevent has the following attributes remotehost domstring readonly remoteport int readonly the datagramsocketevent supports the following methods getbytes() arraybuffer example see here https //stackoverflow\ com/questions/6965107/converting between strings and arraybuffers to learn how to convert between strings and an arraybuffer var bssocketmessage = new bsdatagramsocket(); bssocketmessage bindlocalport(1234) bssocketmessage ondatagram = function(e){ var txtdec = new textdecoder("utf 8"); console log("received " + txtdec decode(e getbytes())); };