diff options
| author | cashmere <cashmere@autistici.org> | 2026-06-22 18:42:46 +0200 |
|---|---|---|
| committer | cashmere <cashmere@autistici.org> | 2026-06-22 18:42:46 +0200 |
| commit | be7fba96face4ab219fb369d2284007807cc536b (patch) | |
| tree | bbc9f02816b75918f29f1dbdc103d673f5b8a724 | |
| parent | 02a025e0597fcfc5b08ed4a360548d94f1bc17b0 (diff) | |
| download | telnet-be7fba96face4ab219fb369d2284007807cc536b.tar.gz | |
src/main.c: respond to client without closing connection
| -rw-r--r-- | src/main.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -33,9 +33,10 @@ int main() { return 1; } char buf[1024]; - ssize_t n = read(conn, buf, sizeof(buf)); - write(conn, buf, n); - close(conn); + ssize_t n; + while ((n = read(conn, buf, sizeof(buf))) > 0) { + write(conn, buf, n); + } } return 0; } |
