7

Why can we not have UDP connection between a browser and a server? Why is TCP connection possible (via WebSockets) and UDP not?

lnogueir
  • 1,859
  • 2
  • 10
  • 21
C graphics
  • 7,308
  • 19
  • 83
  • 134

2 Answers2

5

HTML5 does not allow arbitrary TCP connections.

Instead, web sockets is a special new protocol built on on TCP that allows bidirectional communication.

Similarly, WebRTC is a special new protocol built on UDP that allows peer-to-peer communication.

Allowing arbitrary socket connections would be a major security hole.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
3

You can get access to UDP using WebRTC, which is available in the latest versions of Chrome and Firefox. This lets you do direct browser - browser connections without needing to go via the server, amongst other things.

rjmunro
  • 27,203
  • 20
  • 110
  • 132
  • Nice can we make UDP connections between a browser to a server too? I guess right? – C graphics Jul 15 '13 at 15:52
  • 1
    actually, RTC still needs a server to handshake, which is not clear in from the text shown... – dandavis Jul 15 '13 at 15:56
  • I believe it is possible, yes. You will need to have a server side implementation of the WebRTC protocols. I have heard of such things being talked about, but I don't know of any actual implementation. – rjmunro Jul 15 '13 at 15:57
  • 1
    yup, webRTC uses ICE http://en.wikipedia.org/wiki/Interactive_Connectivity_Establishment to negotiate a the connection, which can be implemented on a server side. using libjingle https://developers.google.com/talk/libjingle/ - you *should* be able to create a client/server udp connection though it might be quite challenging. – benjaminbenben Jul 15 '13 at 16:00