5

I currently have an application that I've made in Flutter and wish to make a web application. This app listens to UDP data, decodes the information and displays it on a screen.

I understand that browsers cannot send UDP data. I do not care about this, I am only interested in listening to the data.

Research:
I understand that sockets.io is TCP only, therefor won't work with my app.
Looking at webRTC, it seems a possibility as it supports both TCP and UDP: Does WebRTC use TCP or UDP?

Would I be able to do what I want to with webRTC? Or is there some other library which would let me do this, or is it impossible?

Note: This web app listens to a local IP address of the user's network.

iProgram
  • 6,057
  • 9
  • 39
  • 80

1 Answers1

8

Short answer : NO. Why ?

Because of security constrains like Distributed Denial of Service (DDOS) attacks, and that make it too vulnerable to make in JavaScript.

The closest technology available (that I know of) for client-side JS is WebRTC

With WebRTC you can use DataChannels over SRTP and ICE as a possible solution.

See Also:

mattdaspy
  • 842
  • 1
  • 5
  • 11
  • The links you have given are about sending UDP data. I want to ONLY LISTEN to UDP data. It it posible to listen? Let me know if I miss understood. – iProgram May 12 '19 at 09:42
  • Thanks for replying. I am already using Node.JS for server-side development, however this wouldn't be able to run on on the client? It is important for me to be able to listen to a connection on the client side as that is where the data is coming from. – iProgram May 12 '19 at 09:47
  • @iProgram, check this post : https://stackoverflow.com/questions/51028442/listen-for-udp-messages-in-express – mattdaspy May 12 '19 at 09:48
  • That's only on server-side though. Mind you, suppose I could make a React Native and an Electron app? This way, I still develop in HTML, CSS and JavaScript, yet get access to native APIs. – iProgram May 12 '19 at 09:51
  • Natively, you can't connect to browser UDP sockets using JavaScript, unfortunately; So sorry about that, you won't be able to get UDP from client using JavaScript... HOWEVER, you can implement the WebRTC on your server and listen to UDP by it, but you'll need to use HTML5 to handle the packs. Or you could use Python to do it all, it'd be easier than scrambling around to find a solution with JavaScript – mattdaspy May 12 '19 at 10:02
  • A few links more for you : https://pythontic.com/modules/socket/udp-client-server-example - https://www.html5rocks.com/en/tutorials/webrtc/datachannels/ - https://tools.ietf.org/html/rfc6455 – mattdaspy May 12 '19 at 10:03
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/193208/discussion-between-iprogram-and-matheus-simoes). – iProgram May 12 '19 at 10:03