Absolutely!
The caveat is that you need something that is necessary for the connection between the browser WebSocket transport protocol 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 (only WebSocket is TCP, so UDP target support will be a bit odd).
The websockify project actually includes two proofs of the concept of HTML / Javascript pages for interacting with IRC and telnet. If you are interested in using websockify to create HTML / Javascript clients for some common TCP protocols, I would even pull them into the websockify repository as examples (assuming they are well encoded and are under an open source license.
An alternative to websockify is to integrate websocket server-side support directly onto the servers you want to communicate with. It is not so difficult to add support. WebSocket has a very simple framework, and although the handshake is compatible with HTTP servers, it is actually much more limited and simple and does not require a full HTTP parser. For example, libvncserver 0.9.9 now supports both regular VNC connections and VNC connections via WebSocket. This allows noVNC (which I also created) to connect directly to the libvncserver based VNC server without requiring websockify.
source share