Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I communicate over TCP sockets from JavaScript?

Tags:

I'm thinking about how limiting it is for AJAX apps to have to poll for updates, when what would be ideal is for javascript to be able to set up a real two way connection to the server. I'm wondering if there is some method of integrating javascript with a browser plugin that can make a tcp connection so that I could pass data into and out of the browser plugin.

like image 530
Luke Avatar asked Nov 21 '08 01:11

Luke


People also ask

How do you call a JavaScript socket?

socket= new WebSocket('ws://www.example.com:8000/somesocket'); socket. onopen= function() { socket. send('hello'); }; socket.

How client and server communicate using TCP sockets?

TCP sockets are used for communication between a server and a client process. The server's code runs first, which opens a port and listens for incoming connection requests from clients. Once a client connects to the same (server) port, the client or server may send a message.

Is Websockets over TCP?

1.7.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.


1 Answers

WebSockets is designed to solve this problem.

like image 98
jnnnnn Avatar answered Oct 11 '22 03:10

jnnnnn