reading-notes

Notes for Codefellows Code 401 301 201 and 102

Readings Class 13: Message Queues

What does it mean that web sockets are bidirectional? Why is this useful?

amx Whereas HTTP relies on a client request to receive a response from the server for every exchange, WebSockets allow for full-duplex bidirectional communication. This enables the server to send real-time updates asynchronously, without requiring the client to submit a request each time. In the context of networked AV and control systems, this allows devices to send and receive continuous streams of data to and from any point on the network.

Does socket.io use HTTP? Why?

socket.io Socket.IO is NOT a WebSocket implementation. Although Socket.IO indeed uses WebSocket as a transport when possible, it adds additional metadata to each packet. That is why a WebSocket client will not be able to successfully connect to a Socket.IO server, and a Socket.IO client will not be able to connect to a plain WebSocket server either.

What happens when a client emits an event?

tutorialspoint Client emits the event and it is handled by the server. There’s a way to even emit the event to all connected clients. NOTE that client and server is the name of the setup in a way. Because each client can become a server and each server can become a client in the strictes sense of the definition (client = sending a request, server listening to a request and serving a response)

What happens when a server emits an event?

Client needs a listener that listens for the event. As the server emits the event the clients .on function picks it up and executes the code inside of it.

What happens if a client “misses” an event?

stackoverflow Unhandled messages are just ignored. It’s just like when an event occurs and there are no event listeners for that event. The socket receives the msg and doesn’t find a handler for it so nothing happens with it.

How can we mitigate this?

stackoverflow You could avoid missing messages by always having the handlers installed and then deciding in the handlers (based on other state) whether to do anything with the message or not.

ALSO could implement a way to store the event logs on the server side and request a confirmation (like a status 200 - or read signal from the client) and then check off the events. If they did not get received/read, you could implement a service routine (like every hour) to check the logs and resend any messages/events

Document the following Vocabulary Terms

Socket

wiki software structure within a network node of a computer network that serves as an endpoint for sending and receiving data across the network. Socket is real time, bi-directional and event-based communication.

Web Socket

wiki a computer communications protocol, providing full-duplex communication channels over a single TCP connection.

Socket.io

socket.io a library that enables real-time, bidirectional and event-based communication between the browser and the server.

Client

wiki a piece of computer hardware or software that accesses a service made available by a server as part of the client–server model of computer networks. CLIENTS make REQUESTS to the SERVER.

Server

wiki a piece of computer hardware or software that provides functionality for other programs or devices, called “clients”. SERVERS LISTEN FOR REQUESTS and SERVE RESPONSES.

OSI Model (Open Systems Interconnection model)

wiki a conceptual model that characterises and standardises the communication functions of a telecommunication or computing system without regard to its underlying internal structure and technology. Its goal is the interoperability of diverse communication systems with standard communication protocols.

TCP Model

wiki specifications for translating the network addressing methods used in the Internet Protocol to link-layer addresses, such as media access control (MAC) addresses

TCP

wiki Transmission control protocol. TCP provides reliable, ordered, and error-checked delivery of a stream of octets (bytes) between applications running on hosts communicating via an IP network.

UDP

wiki User Datagram Protocol - With UDP, computer applications can send messages, in this case referred to as datagrams, to other hosts on an Internet Protocol (IP) network

Packets

wiki a formatted unit of data carried by a packet-switched network. A packet consists of control information and user data - also known as the payload.


Preview

Skim the following materials in preparation for the upcoming lecture. Note the following as you browse the material, and be prepared to participate in discussions during lecture

Preparation Materials

Socket.io Chat Example

Rooms and Namespaces

Socket.io Emit Cheatsheet