Yes and no.
Not
WebSockets are not raw TCP connections. They have a handshake compatible with HTTP (both for security and compatibility with existing servers), and each package requires minimal framing to make WebSockets a message-based protocol. In addition, the current API and WebSocket protocol, which exists in browsers today, do not directly support binary data messages. They encode only UTF-8.
Yes
You can use websockify to proxy a WebSockets connection to a raw binary TCP server. websockify is a proxy / python bridge that has binary support and also includes a javascript library to make it easier to interact with. In addition, websockify includes web-socket-js fallback / polyfill (embedded in Flash) for a browser that does not have built-in WebSockets support. The downside is that you have to run websockify somewhere (either on the client system, and on the server system, or on some other system). In addition, websockify is Linux / UNIX just now. Websockify, on the other hand, has a special mode that you can use to start and migrate an existing service.
Disclaimer: I did websockify.
source share