-
Web Socket is a communication protocol that allows for two-way data transfer over a single TCP connection.
-
The client sends a handshake request, the server sends a handshake response, then the client and server can send web socket data back and forth
-
Web Sockets provide a standardized way for the server to send content to a client without first receiving a request from that client.
-
The
io.on
event handler handles connection, disconnection, etc., events in it, using the socket object. -
Console log whenever a connection or disconnect event happens.
-
socket.emit
creates and fires a custom event.
- Web Socket is a protocol and socket.io is a library that implements that protocol.
A seven layer standard for getting things to connect to each other.
-
Application: a set of protocols to help application connect, e.g. http or ftp
-
Presentation: establishes data formatting and is responsible for translation (e.g. ASCII to base64), data compression, and encryption.
-
Session: sets up and manages connections, including DNS and authentication/authorization
-
Transport: maintains integrity of transfer, coordinating transfer rates, segmenting and reassembling data, and chacking that all data got the destination.
-
Network: the map that tells you how to get from one node to another.
-
Data Link: Lets individual machines talk to the network
-
Physical: The actual physical machine; converts digital data into a transmission medium, e.g. electrical or radio signals.
-
TCP is a 3 step protocol to establis a connection between te server and client.
-
The client says "I would like to open a connection. Here's what you need to connect to me."
-
The server says "Great, you are connected. Here's what you need to make it a two way connection."
-
The client says "Swell, we now have a two-way connection."
-