diff options
| author | cashmere <cashmere@autistici.org> | 2026-06-22 17:15:10 +0200 |
|---|---|---|
| committer | cashmere <cashmere@autistici.org> | 2026-06-22 17:15:10 +0200 |
| commit | 651737ad00147b58378024018ba168cafdc12e47 (patch) | |
| tree | 276678a900ea0bc08d00a41886122b633fc9b37f /src | |
| parent | 876cf39b6f133b15f266a93fefcb7f3dc544aac7 (diff) | |
| download | telnet-651737ad00147b58378024018ba168cafdc12e47.tar.gz | |
src/main.c: accept connection and respond with string
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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; } |
