Menu

1 / 2

SSH Flow Control, and Why an SSH Client Must Keep Reading While It Writes

DEV Community: rust·c-wind·about 2 hours ago
#WJ9Fp4nj
#devtorust#devto#dev#window#terminal
Reading 0:00
15s threshold

Originally published on MistLab . Part 2 of Building an SSH Terminal .

Part 2 of "Building an SSH Terminal". Code excerpts are from MistTerm v1.2.26, an open-source (AGPL) SSH terminal client by MistLab; they are trimmed

TL;DR

SSH flow control gives each direction of each channel a window : the number of bytes the sender may still send before the receiver grants more with SSH_MSG_CHANNEL_WINDOW_ADJUST (RFC 4254 §5.2). When the send window is zero, the client must keep reading the server's output. Otherwise it and the remote program can wait on each other forever. Keep network I/O off the GUI thread, and bound every wait.

Part 1 treated the terminal as a pipe that hands bytes to a parser. Those bytes come from, and keystrokes go to, an SSH channel on a server PTY.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.