Alex Rivera | Logout

How to establish a TCP Socket connection from a web browser (client side)?

Asked 2011-11-08T13:57:42.327
30

I've read about WebSockets but they don't seem to be pure "sockets", because there is an application layer protocol over them. "ws:"

Is there any way of doing a pure socket connection from a web browser, to enliven webpages?

Here are my random stabs in the dark

  • Applets sockets provided by Java (need java installed)
  • Flash sockets provided by Flash (need flash installed)

But about HTML5, Why are they called WebSockets if they aren't Sockets?

Is the websocket protocol so simple to implement that it is "almost"-sockets?

Edit
Report

1 Answer

2

You can just send data between a client and a server with WebSockets. Simply speaking, the only difference that WebSockets introduces is that the client:

  • adds some header bytes, like the type of data and the length
  • adds masks and encodes the data using them

The server also has to add header bytes, but does not need to encode the data.

If you implement the protocol correctly (server side, that is, since the browser already has an implementation), you can use it with ease to send text and binary data. (Although browser support is narrow, especially for the latter.)

answered 2011-11-08T14:02:36.267

Your Answer