summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorcashmere <cashmere@autistici.org>2026-06-22 17:15:10 +0200
committercashmere <cashmere@autistici.org>2026-06-22 17:15:10 +0200
commit651737ad00147b58378024018ba168cafdc12e47 (patch)
tree276678a900ea0bc08d00a41886122b633fc9b37f /src/main.c
parent876cf39b6f133b15f266a93fefcb7f3dc544aac7 (diff)
downloadtelnet-651737ad00147b58378024018ba168cafdc12e47.tar.gz
src/main.c: accept connection and respond with string
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index ee8710d..71cea19 100644
--- a/src/main.c
+++ b/src/main.c
@@ -26,9 +26,12 @@ int main() {
perror("could not listen");
return 1;
}
- printf("hello world\n");
-
- int ac = accept(sfd, (struct sockaddr *)&addr, NULL);
- printf("client connected");
+ int ac = accept(sfd, NULL, NULL);
+ if (ac == -1) {
+ perror("could not accept");
+ return 1;
+ }
+ const char *buf = "Hello from telnet!\n";
+ write(ac, buf, strlen(buf));
return 0;
}