Streams
A stream is a bidirectional flow of bytes that in a given connection may carry one or more messages. Each stream is identified by an integer that will be written on the header of any frame.
Note that in a single TCP connection, several streams may be active concurrently at the same time.
Streams have lifecycles and they are represented by transitions among states. These are all the possible states:
- Idle: Initial state for any opened stream.
- Open: State where both peers may send or receive frames at any moment.
- Reserved: One of the peers, having the stream in Idle state, sent a
PUSH_PROMISE
frame in order for the server to begin to push messages to the client. - Half Closed: One of the peers finished to send frames.
- Closed: Both peers agreed to terminate the connection.
Here you can see the workflow: