refactor(socket): delete socket

This commit is contained in:
2026-03-16 23:09:26 +01:00
parent d777b9be7f
commit f729463ab3
5 changed files with 4 additions and 179 deletions
-43
View File
@@ -1,43 +0,0 @@
#include "../socket/mysocket.h"
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
void test_socket1(void) {
sock_platform_init();
struct addrinfo hints, *res, *p;
char ipstr[INET6_ADDRSTRLEN];
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
char hostname[1024];
printf("hostname> ");
fscanf(stdin, "%s", hostname);
if (getaddrinfo(hostname, NULL, &hints, &res) != 0) {
fprintf(stderr, "getaddrinfo() failed\n");
sock_platform_shutdown();
return;
}
for (p = res; p != NULL; p = p->ai_next) {
void *addr = 0;
char *ipver = 0;
struct sockaddr_in *ipv4;
if (p->ai_family == AF_INET) {
ipv4 = (struct sockaddr_in *)p->ai_addr;
addr = &(ipv4->sin_addr);
ipver = "IPv4";
} else {
continue;
}
inet_ntop(p->ai_family, addr, ipstr, sizeof ipstr);
printf("%s: %s\n", ipver, ipstr);
}
freeaddrinfo(res);
sock_platform_shutdown();
}
+3 -3
View File
@@ -17,7 +17,7 @@ void test_vec1(void);
void test_stack1(void);
void test_socket1(void);
void test_set1(void);
int main(void) {
puts("==== [Running Hashmap tests] ====");
@@ -47,8 +47,8 @@ int main(void) {
puts("OK!");
puts("");
puts("==== [Running Socket tests] ====");
test_socket1();
puts("==== [Running Set tests] ====");
test_set1();
puts("OK!");
puts("");