Giter Site home page Giter Site logo

Comments (9)

oahziur avatar oahziur commented on August 23, 2024

Did you bind the port before sent the message?

from cordova-plugin-chrome-apps-sockets-udp.

Kobzol avatar Kobzol commented on August 23, 2024

I tried it both with and without binding the socket without send, neither worked.
If I bind the socket before send, it works (except for the receive), but it gives me an iOS error in the console saying that the port cannot be bound mpre than once.

from cordova-plugin-chrome-apps-sockets-udp.

nicojanssens avatar nicojanssens commented on August 23, 2024

What's the current status of this issue?

I'm facing similar problems, my Cordova app doesn't receive UDP messages when running on an iDevice. Chrome app works fine.

from cordova-plugin-chrome-apps-sockets-udp.

Kobzol avatar Kobzol commented on August 23, 2024

It turned out that I was sending with the UDP socket before it was properly initialized. I created a promise that resolves after the initialization (chrome.sockets.udp.create function) and do all the sends after that promise is resolved. After that it works fine, so it was a problem with my code. I'm binding the socket to "0.0.0.0" and port 0 (auto-select) before sending data through it.

from cordova-plugin-chrome-apps-sockets-udp.

nicojanssens avatar nicojanssens commented on August 23, 2024

Thanks, @Kobzol.

It turned out that the root cause of my problem was slightly different from yours, but your suggestions definitely helped me squashing my bug.

from cordova-plugin-chrome-apps-sockets-udp.

Smiral97 avatar Smiral97 commented on August 23, 2024

I'm having problems with receiving UDP sockets on iOS.
I create a socket on iPhone, send a message, the other side receives it and sends a response to the phone's address (IP, port), but the callback registered with onReceive doesn't fire.
The same code works without problems on Android.
I tried setting the socket as persistent, that didn't help.
Is there anything extra that has to be done for this to work?

Have you found the solution?I have a exact same problem.. HELP!

from cordova-plugin-chrome-apps-sockets-udp.

Kobzol avatar Kobzol commented on August 23, 2024

I described the solution in a comment above (#9 (comment)). I was using the socket before it was initialized, you need to make sure that everything happens only after all callbacks are processed (initialization, port bind etc.). I also had some issues with broadcast, for that I needed to enable the broadcast flag on the socket.

from cordova-plugin-chrome-apps-sockets-udp.

Smiral97 avatar Smiral97 commented on August 23, 2024

I described the solution in a comment above (#9 (comment)). I was using the socket before it was initialized, you need to make sure that everything happens only after all callbacks are processed (initialization, port bind etc.). I also had some issues with broadcast, for that I needed to enable the broadcast flag on the socket.

But in my android device it is working perfectly. Here is my code.

Screenshot 2019-12-24 at 3 42 33 PM

code flow does not go in the onReceive method in ios

from cordova-plugin-chrome-apps-sockets-udp.

Kobzol avatar Kobzol commented on August 23, 2024

If you're setting the port to 0, that means that you can only pretty much receive broadcast packets (otherwise the other side wouldn't know which port to send to). In that case you have to enable broadcast (chrome.sockets.udp.setBroadcast(sockId, true, callback)) and only bind after the broadcast is enabled.

from cordova-plugin-chrome-apps-sockets-udp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.