Node.js
/Advanced
Duplex Streams
Definition
A stream that implements both Readable and Writable interfaces. It represents a two-way communication channel.
Explain Like I'm New
A Walkie-Talkie or a Telephone. You can speak into it (Writable) AND you can listen to it (Readable) at the exact same time. The data you write is entirely independent of the data you read.
Real World Example
A TCP Network Socket. When a user connects to your multiplayer game, you get a Duplex Stream. You `read` from it to see their joystick movements, and you `write` to it to send them the positions of the other players.
Common Use Cases
- •Network sockets (TCP)
- •WebSockets
Interactive Example
Loading...
Console output will appear here...
Interview Questions
basic
- What is an example of a Duplex stream?
intermediate
- Is the readable side connected to the writable side in a Duplex stream?