Using UDP in Ionic

Hi, iam trying to make my ionic app communicate with server ovet UDP, but iam a little lost. Has anyone some experience with this, or some working example how to establish this type of communication?

Did u search this forum on udp keyword?

yea i tried, but it seems a little ovewhelming. As i see, there is plugin for that, so first i use chrome.sockets.udp.create then i connect to it, and now i can send some data. But iam a little confused what arrayBuffer is, and if i had to use bind function also. So some actual working example would be nice, how to send some data and how to receive some data over UDP

My past fiddles to discover sonos on udp

Not sure why I stranded

thx a lot, i have just two more questions :

What exactly this line does? chrome.sockets.udp.bind(createInfo.socketId, ‘’, port, (bindresult) => {

And second, how do u install plugin and run it? I installed it over npm, then i use declare var chrome on beginning of my typescript file, but it says reference error, chrome not found


I actually had no clue what it did, I just included it after taking it from an example somewhere (I had to scrape many sites to get it to work).

The plugin you need to do an install of “cordova-plugin-chrome-apps-sockets-udp” through ionic cordova install cordova-plugin-chrome-apps-sockets-udp (I believe).

Just check your config.xml to see if it is included as plugin

hi, plugin works, but i have one more question. There is problem with adding listener OnReceive. When i do all the things (creating socket, binding, adding listener, closing) everytime i send udp data, the listeners starts to stack, it seems like close method doesnt remove listener. Any ideas how to fix this?

Manually remove listener?

Dont know by heart but it is likely default js

This is how i’ve done it.

closeUDPService() {
        // close the socket
        if (typeof chrome.sockets !== 'undefined') {
        // close the stream