w11- socket Flashcards

1
Q

Realtime Bidirectional Event-Based Communication

A

If a server wants to push (send) data to a client, the client has to send an HTTP first; is there a way to send messages from the server to clients in real-time?
Answer: Yes. WebSocket protocol provides a full-duplex communication channel through a single TCP/IP connection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Socket.io?

A

library that enables real-time, bidirectional and event-based communication between the browser and the server. It consists of:

a Node.js server

a Javascript client library for the browser
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Socket.io main features?

A

Reliability

Auto-reconnection support:

Unless instructed otherwise, a disconnected client will try to reconnect until the server is available again.

Disconnection detection

A heartbeat mechanism is available, allowing the server and the client to know when the other one is not responding anymore.

Binary support:

Any serializable data structures can be emitted.

Multiplexing support:

To create the separation of concerns within your application (for example, per module or based on permissions), Socket.IO allows you to create several Namespaces, which will act as separate communication channels but share the same underlying connection.

Room support:

Within each Namespace, you can define arbitrary channels, called Rooms, that sockets can join and leave. You can then broadcast to any room, reaching every socket that has joined it. This is a useful feature to send notifications to a group of users or a given user connected to several devices, for example
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Socket.io is attached to an instance of —-

A

http.server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly