summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcashmere <cashmere@autistici.org>2026-06-22 18:35:04 +0200
committercashmere <cashmere@autistici.org>2026-06-22 18:35:04 +0200
commit02a025e0597fcfc5b08ed4a360548d94f1bc17b0 (patch)
tree67e5df4345e799cfc5b7304e32920322fb39e67e
parent529285ac3b511a6eb5ebf570fd3c6bda5fa0cfdf (diff)
downloadtelnet-02a025e0597fcfc5b08ed4a360548d94f1bc17b0.tar.gz
src/main.c: add echo functionality
-rw-r--r--src/main.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 33139b6..38aec51 100644
--- a/src/main.c
+++ b/src/main.c
@@ -32,8 +32,9 @@ int main() {
perror("could not accept connection");
return 1;
}
- const char *buf = "Hello from telnet!\n";
- write(conn, buf, strlen(buf));
+ char buf[1024];
+ ssize_t n = read(conn, buf, sizeof(buf));
+ write(conn, buf, n);
close(conn);
}
return 0;