Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible for WebSocket client on browser to talk to TCP Socket server?

Is it possible to have a TCP Socket server running which accepts incoming connections from WebSocket clients? I have a TCP Socket server and I'd like to be able to test this in a browser. Is this possible?

like image 230
jaffa Avatar asked Mar 01 '13 15:03

jaffa


People also ask

Can WebSocket connect to socket?

WebSocket is a special protocol that uses HTTP for handshake and use the underlaying socket to do the real communication afterwards. So, you cannot connect to a regular tcp socket with websocket because they are two different things.

Does browser support TCP?

Web browsers do not support communicating with TCP hosts, other than web servers. In this post I take a different tack. I demonstrate a relay written with Node. js, that receives data from the browser over websockets, and sends it to a TCP socket.

Does WebSocket use TCP or HTTP?

WebSocket uses a unified TCP connection and needs one party to terminate the connection. Until it happens, the connection remains active. HTTP needs to build a distinct connection for separate requests. Once the request is completed, the connection breaks automatically.

Are WebSockets over TCP or UDP?

The WebSocket protocol is an independent TCP-based protocol.


1 Answers

Absolutely! That is the purpose of websockify.

Of course your WebSocket client application will need to be able to implement the protocol of the TCP server. For example, noVNC is a browser VNC client that implements the RFB protocol and by using websockify it can connect to a normal TCP based VNC server.

Disclaimer: I created both websockify and noVNC

like image 66
kanaka Avatar answered Oct 21 '22 00:10

kanaka