Formatting ......

This commit is contained in:
Imbus 2025-05-12 12:09:54 +02:00
parent 5392c8e418
commit 655b310328
2 changed files with 67 additions and 66 deletions

14
sock.c
View file

@ -1,10 +1,10 @@
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/socket.h>
#include <unistd.h>
int main(void) {
// Get TCP protocol entry
@ -25,11 +25,12 @@ int main(void) {
struct sockaddr_in server_addr = {
.sin_family = AF_INET,
.sin_addr.s_addr = htonl(INADDR_ANY), // Bind to any available address
.sin_port = htons(8080) // Port 8080
.sin_port = htons(8080) // Port 8080
};
// Bind socket
if (bind(server_fd, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
if (bind(server_fd, (struct sockaddr *)&server_addr, sizeof(server_addr)) <
0) {
perror("bind failed");
close(server_fd);
return EXIT_FAILURE;
@ -47,7 +48,8 @@ int main(void) {
// Accept one client connection
struct sockaddr_in client_addr;
socklen_t client_len = sizeof(client_addr);
int client_fd = accept(server_fd, (struct sockaddr *)&client_addr, &client_len);
int client_fd =
accept(server_fd, (struct sockaddr *)&client_addr, &client_len);
if (client_fd < 0) {
perror("accept failed");
close(server_fd);