Questions tagged [websocket]

WebSocket is an API built on top of TCP sockets and a protocol for bi-directional, full-duplex communication between client and server without HTTP overhead.

WebSockets (or WebSocket) is an API and a protocol for bi-directional, full-duplex communication over TCP sockets. The WebSockets API was originally part of the HTML5 standard, but it has been split off into a separate W3C standard. The WebSockets protocol is an IETF standard described in RFC 6455.

The WebSockets API has full browser support in Chrome 14, Firefox 6, IE 10 (desktop and mobile), Opera 12.1 (desktop and mobile), Safari 6.0 (desktop and mobile), Android 4.4, Chrome Mobile, and Firefox Mobile. Some older browsers have partial support or can be supported using a Flash based fallback.

WebSockets supports both unencrypted and encrypted connections. Unencrypted connections use the "ws://" URL scheme and default to port 80. Encrypted connections use the "wss://" URL scheme and default to port 443. Encrypted connections use Transport Layer Security (TLS).

Simple WebSockets browser JavaScript example:

if ("WebSocket" in window) {
    var ws = new WebSocket("ws://echo.websocket.org/");
    ws.onopen = function() {
        console.log("WebSockets connection opened");
        ws.send("a test message");
    }
    ws.onmessage = function(e) {
        console.log("Got WebSockets message: " + e.data);
    }
    ws.onclose = function() {
        console.log("WebSockets connection closed");
    }
} else {
    // No native support
}

Useful Links

Books

27923 questions
8
votes
3 answers

Web Sockets on Samsung Galaxy S3 Android Browser?

So, apparently the webapp we did, that uses websockets, does not work on the Samsung Galaxy S3 stock Android browser. The thing is, Android Browser is not supposed to have web sockets support, but it looks like this one has, although the websockets…
Benjamin Michel
  • 131
  • 1
  • 6
8
votes
3 answers

TypeScript with WebSocket

I have a webapp with JavaScript and websocket applied inside the webapp, Now, I wanted to try to move my webapp to typescript which is type safe, The problem is, when I declare and initialize the websocket, the typescript (in visual studio 2012)…
Eldon Lesley
  • 915
  • 6
  • 19
  • 38
8
votes
2 answers

Is there a socket.io port to Dart?

I've taken a look at the basic websocket capabilities in Dart, using this simple example: https://github.com/financeCoding/chat-websocket-dart But I was wondering if there's a nice library I could use to build a realtime online game using…
meltuhamy
  • 3,293
  • 4
  • 23
  • 22
8
votes
2 answers

WebRTC the right one? (realtime multiplayer game)

Imagine I want to create a realtime multiplayer game, with HTML5 (client) and node.js (server). I need to transport data very fast from the server to the clients and vice versa. In a native application I would use UDP for the most data (player…
appsthatmatter
  • 6,347
  • 3
  • 36
  • 40
8
votes
6 answers

using html5 client with a server in java

HTML5 client reduce prograamers effort by providing client in html5 websocket client. It will be beneficial to many programmers to learn how to use this html5 websocket client with server in java. i want to create an Example of HTML5 client…
Hemant Metalia
  • 29,730
  • 18
  • 72
  • 91
8
votes
4 answers

How to disconnect from localhost?

Is it possible to disconnect from localhost? I'm writing a Node.js WebSocket server, and I want to test locally what would happen if the connection closes erroneously. If I were testing remotely, I'd just Turn Wi-Fi Off, but that doesn't disconnect…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
8
votes
2 answers

Socket.io session without express.js?

I want to make a sessionhandling over websockets via node.js and socket.io without necessarily using cookies and avoiding express.js, because there should be also clients not running in a browser environment. Somebody did this already or got some…
Felix Gertz
  • 175
  • 2
  • 8
8
votes
2 answers

On device iOS websocket server

Looking to implement websockets communication between a UIWebView in iOS with javascript to a local on the device websockets server in objective-c. Anyone seen a sample code set for setting a local websocket server on device for iOS so that the web…
tekgeek
  • 81
  • 1
  • 4
8
votes
1 answer

Websocket connection setup

I am trying to learn more about websocket and its internal implementations. But still can’nt understand few things. I tried googling for a in-depth explanation, but most of them just gives the high-level overview. Following are my doubts 1.…
SysAdmin
  • 5,455
  • 8
  • 33
  • 34
8
votes
3 answers

How to develop a web-based XMPP chat facility using PHP and JQuery?

I am looking to develop a website which features a chat facility between a website visitor and the website administrator. I know the best way to do this would be using XMPP, however I have no experience using it. I am looking to implement this using…
P3tro
  • 139
  • 1
  • 3
  • 9
8
votes
1 answer

Redirecting websocket traffic on port 80 with lighttpd

I have a website hosted on lighttpd, accessible at the "www" subdomain. I also have a chat server listening on port 8124 made with node.js and socket.io. I want all client traffic to happen on port 80, by redirecting all requests to the "chat"…
lortabac
  • 589
  • 4
  • 16
8
votes
2 answers

understanding websockets on the server side

I have a some questions in understanding websocket communication. AFAIU, in client side, it works like this: From client, a new Socket handler is created using "new WebSocket('ws://blahblah')" Then using onOpen() method its known that we are…
siva
  • 1,105
  • 4
  • 19
  • 38
8
votes
3 answers

How can I authenticate user in Play's 2.0 WebSocket?

ellou' I have common Play WebSocket method which is working as expected, but I need to authenticate user. Unfortunately when trying even simplest way to identify user in the method: public class Application extends Controller { public static…
biesior
  • 55,576
  • 10
  • 125
  • 182
8
votes
4 answers

How can I implement a simple web server using Python without using any libraries?

I need to implement a very simple web-server-like app in Python which would perform basic HTTP requests and responses and display very basic output on the web page. I am not too concerned about actually coding it in Python, but I am not sure where…
antonpug
  • 13,724
  • 28
  • 88
  • 129
7
votes
1 answer

How Can a LAMP Guy Easily Implement WebSockets?

I've always worked with Apache, MySQL, and PHP. I'd like to eventually branch out to Python/Django or Ruby/Ruby on Rails, but that's another discussion. Two great things about Apache, MySQL, and PHP are all three are ubiquitous and it's very easy to…
Nick
  • 8,049
  • 18
  • 63
  • 107
1 2 3
99
100