adds more examples

This commit is contained in:
ergz 2023-04-11 02:18:43 -07:00
parent 079886e767
commit 18ff0c1bf3
1 changed files with 27 additions and 6 deletions

33
main.c
View File

@ -91,15 +91,36 @@ int main()
}
char ip4[INET_ADDRSTRLEN];
struct sockaddr_in sa; // ipv4 ip address
// char ip4[INET_ADDRSTRLEN];
// struct sockaddr_in sa; // ipv4 ip address
inet_pton(AF_INET, "10.12.110.57", &(sa.sin_addr));
inet_ntop(AF_INET, &(sa.sin_addr), ip4, INET_ADDRSTRLEN);
// inet_pton(AF_INET, "10.12.110.57", &(sa.sin_addr));
// inet_ntop(AF_INET, &(sa.sin_addr), ip4, INET_ADDRSTRLEN);
printf("the ipv4 address is: %s\n", ip4);
// printf("the ipv4 address is: %s\n", ip4);
// printf("hellow world!\n");
int status;
struct addrinfo hints;
struct addrinfo *servinfo;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
status = getaddrinfo(NULL, "3490", &hints, &servinfo);
if (status != 0) {
fprintf(stderr, "getaddrinfo error: %s\n", gai_strerror(status));
exit(1);
}
freeaddrinfo(servinfo);
printf("hellow world!\n");
return(0);
}