1

Alright so I have a C++ game server which I wanna connect to via UDP and Javascript, but I'm not sure how to do that. WebSockets don't seem to work as they only supports TCP and WebRTC doesn't seem to work either for this kind undertaking (at least from what I've read).

I wouldn't mind using technologies that are in beta-stage and therefore not available on all platforms, as as long as they are available in Chrome (Canary).

Nik
  • 420
  • 1
  • 5
  • 15
  • 1
    You mean JavaScript from a web browser, right? If so, I believe the answer is that there's no way to do that (currently). – Pointy May 19 '13 at 21:51
  • Ah sorry, yes from a web browser. Ah what a bummer ): – Nik May 19 '13 at 21:52
  • [This question](http://stackoverflow.com/questions/13216785/how-to-send-a-udp-packet-with-web-rtc-javascript?rq=1) and [this one also](http://stackoverflow.com/questions/13811854/can-i-use-webrtc-to-open-a-udp-connection?rq=1) describe the WebRTC approach, for what that's worth. You may have to create a server-side WebSocket bridge or something. – Pointy May 19 '13 at 21:54
  • The peer-to-peer Data Channel API seems to be what I'm looking for, except that it only works within browsers. Anyway, I'll check out the rest of the things discussed in those questions, thanks – Nik May 19 '13 at 21:58
  • I just checked out webrtc4all but it seems like their UDP implementation (and for that sake, any other implementation as well) only works from one browser to another. guess this mean that there's is currently no solution to my problem – Nik May 19 '13 at 22:07

2 Answers2

1

You can also built Javascript+Flash bridge and use Adobe Flash Player RTMFP protocol which based on UDP. If you need raw UDP or similar, you should better use WebRTC data channel.

Nick
  • 587
  • 1
  • 5
  • 9
1

You won't be able to use UDP directly. That's a fundamental property of the web sandbox. See Can I use WebRTC to open a UDP connection?

If you want to talk directly, you can with data channels, but that is going to need a bunch of things over and above UDP on the server side. ICE, DTLS and SCTP are needed, see https://datatracker.ietf.org/doc/html/draft-ietf-rtcweb-transports. The standards are still somewhat in flux there, so I'm not sure that you want to dive into that morass right away.

Community
  • 1
  • 1
Martin Thomson
  • 3,433
  • 2
  • 16
  • 13