4

Is it possible in javascript/HTML5 (no node.js) to make a direct bilateral connection to an UDP server ? There's WebRTC but from want I understand you can't send datagram to a specific server.

My main concern is to make a game that communicates with his server over UDP, so I know the server's address, no need of ICE or such things like that...

Thank you

iliak
  • 61
  • 1
  • 4

1 Answers1

2

You cannot in native javascript open direct UDP/TCP ports. It is designed this way for security purposes.

You will have to put in a breaker between your frontend and the destination server(I would say websockets to udp). So, have a websocket server in C(possibly with libwebsockets) to communicate to your web app and then translate the data and push it over UDP

There are breakers that already exist for specific purposes Check out this so question

Community
  • 1
  • 1
Benjamin Trent
  • 7,378
  • 3
  • 31
  • 41
  • I'm making the client and the server so it wouldn't be a problem about websocket communication. The problem would be the "delay" (introduced by TCP over UDP) between the client and the server during the gameplay... In any case, I will use this technique and see what happens ... Thank you ! – iliak Apr 29 '14 at 12:05