Meaning of socket and how to program in JavaScript.
If you want anything more in depth than what j explained, I HIGHLY RECOMMEND reading Beej's Guide. It's DAMN good at explaining this stuff:
A socket is one of the most fundamental technologies of computer network programming . It is a way of connecting two nodes on a network to communicate with each other. Socket-based software usually runs on two separate computers on the network, but sockets can also be used to communicate locally (interprocess) on a single computer.
The Java Socket Programming has two sections.
Java Server Socket Program
Java Client Socket Program
More on.... Java Socket Programming
Two processes that run on the same machine, or different machines, communicate through sockets. Sockets are seen as the end of the two-way communication between two processes.
For more information,refer the following link:
Imagine this:
Visiting a website (or downloading a file):
Client texts Server: "Hey, send me X please"
Server texts Client: "Here it is: [data]"
Now compare this to a socket connection:
Client calls server: "Hey, whats up?"
Server: "Hey, good, i'm holding the phone, talk to me when needed"
Client: "Sure, and if you have something to say, I'm listening"
.... Time passes by ...
Server to client: "Hey you there? I just wanted to tell you [data]"
... Time passes by ...
Client to server: "Hey what about X?"
... and conversation goes on ...
Now the side effect of a TCP socket connection is that the server needs to "hold the phone" for all incoming traffic and communicate with them. As opposed to simple HTTP requests ("SMS messages") that can be cached or delegated - it requires more resources.
j
stuff ;)
a socket in this context means an open TCP connection between the server and the client
developer.mozilla.org/en-US/docs/Web/API/WebSocket
the advantage of this open connection is that your server and your client can communicate without having the overhead of an HTTP request.
so you can push messages from the client to the server and back. this messages are strings -> these string can be parsed to jsons, xmls, and other formats your client supports.
server gets an update -> pushes it to the clients.
does this explanation help ? This is really just a rough summary.