Skip to content

Commit 6ed3f79

Browse files
committed
[examples/echo.c3] add "quit" client command
1 parent 5c4aadf commit 6ed3f79

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

examples/echo.c3

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ fn void main() {
3333
usz n = client_sock.read(buf)!!;
3434
if (n == 0) break OUTER;
3535
char[] chunk = buf[0:n];
36+
37+
if (((String)chunk).trim() == "quit") {
38+
io::printfn("[%d] Client requested to quit", coroutine::id(), chunk.len);
39+
return;
40+
}
41+
3642
io::printfn("[%d] Client sent %d bytes", coroutine::id(), chunk.len);
3743

3844
while (chunk.len > 0) {

0 commit comments

Comments
 (0)