Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I connect to irc, icq, sip, etc services using WebSockets providing I have some sort implementation of those protocols in JavaScript?

I would like to connect to to irc, icq, sip, etc services using WebSockets. Assuming I have some sort implementation of those protocols in JavaScript ? Is that possible? I don't seems to understand limitations of WebSockets comparing to regular sockets.

like image 706
xchg.ca Avatar asked Jun 22 '12 21:06

xchg.ca


People also ask

Does IRC use WebSockets?

1) A web browser connects to it, 2) It then connects to an IRC network, 3) The data between the two connections are then passed back and forth with any required encoding. Most IRC networks currently do not support websocket connections or will only support native websockets.

How do I connect to WebSockets?

All you have to do is call the WebSocket constructor and pass in the URL of your server. // Create a new WebSocket. var socket = new WebSocket('ws://echo.websocket.org'); Once the connection has been established, the open event will be fired on your Web Socket instance.

Which protocol is used by WebSockets?

The WebSocket protocol is an independent TCP-based protocol. Its only relationship to HTTP is that its handshake is interpreted by HTTP servers as an Upgrade request. By default the WebSocket protocol uses port 80 for regular WebSocket connections and port 443 for WebSocket connections tunneled over TLS [RFC2818].

How does WebSocket connection work?

In WebSocket, communication occurs at both ends, which makes it a faster protocol. In HTTP, the connection is built at one end, making it a bit sluggish than WebSocket. WebSocket uses a unified TCP connection and needs one party to terminate the connection. Until it happens, the connection remains active.


3 Answers

No, you can't, at least not directly.

WebSockets allow real-time messaging between a browser and a WebSocket server, but they have their own layer 7 protocol for encapsulating those messages.

They don't provide access to a pure TCP (or UDP) socket over which you can implement existing protocols.

like image 96
Alnitak Avatar answered Oct 07 '22 02:10

Alnitak


Absolutely!

The caveat is that you need something to bridge between the WebSocket transport protocol of the browser and the raw TCP socket of the existing service. For example, something like websockify (disclaimer: I created websockify). Another caveat is that websockify only supports TCP targets (WebSocket is TCP only right now so supporting UDP targets would be a little odd anyways).

The websockify project actually includes two proof of concept HTML/Javascript pages to communicate with IRC and telnet. If you are interested in leveraging websockify to build HTML/Javascript clients for some common TCP protocols, I might even pull them into the websockify repo as examples (assuming they are well coded and under an open source license.

An alternative to websockify is to integrate websocket server-side support directly into the servers you wish to communicate with. It's not all that difficult to add support. WebSocket has a very simple framing and while the handshake is compatible with HTTP servers it's actually much more restricted and simple and doesn't require a full HTTP parser. For example, libvncserver 0.9.9 now supports both regular VNC connections and VNC connections over WebSocket. This allows noVNC (which I also created) to connect directly to a libvncserver based VNC server without requiring websockify.

like image 45
kanaka Avatar answered Oct 07 '22 02:10

kanaka


Inspircd has an unofficial module you can install called m_websockets, to allow connection. A server that has the module installed and setup will allow you to connect to the server via webbsockets.

https://github.com/barosl/inspircd-m_websocket

like image 40
Jamezs Gladney Avatar answered Oct 07 '22 02:10

Jamezs Gladney