Renamed examples for logical ordering

This commit is contained in:
seajee
2025-08-24 23:56:09 +02:00
parent ad986c777a
commit 024377795d
11 changed files with 0 additions and 0 deletions

28
examples/03-udp_client.c Normal file
View File

@@ -0,0 +1,28 @@
#include <stdio.h>
#include <string.h>
#define SOCK_IMPLEMENTATION
#include "sock.h"
int main(void)
{
Sock *client = sock_create(SOCK_IPV4, SOCK_UDP);
if (client == NULL) {
perror("sock_create");
return 1;
}
SockAddr server_addr = sock_addr("127.0.0.1", 6969);
const char *msg = "Hello from client!";
ssize_t sent = sock_sendto(client, msg, strlen(msg), server_addr);
if (sent < 0) {
perror("sock_sendto");
sock_close(client);
return 1;
}
printf("Sent message: %s\n", msg);
sock_close(client);
return 0;
}