Commit 080bdafa authored by Maia Jejelava's avatar Maia Jejelava
Browse files

get_addresses added.

parent e243597b
......@@ -15,6 +15,8 @@
#include <stdio.h>
#define BUFFER_SIZE (1<<16)
#define MESSAGE_SIZE (9216)
#define NI_MAXHOST 1025
//daytime tcp
#define LISTENQ 5 //Maxnumbers of clients
......
//
// Created by user on 27.11.21.
//
#include "Socket.h"
int main(int argc, char* argv[]) {
struct addrinfo *result, *entry;
if (argc != 2) {
printf("Invalid arguments");
return 1;
}
int ret;
if ((ret = getaddrinfo(argv[1], NULL, NULL, &result))) {
printf("getaddinfo()");
return 2;
}
for (entry = result; entry != NULL; entry = entry->ai_next) {
char hostname[NI_MAXHOST] = "";
getnameinfo(entry->ai_addr, entry->ai_addrlen, hostname, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
printf("%s Protocol: %d, Socktype: %d\n", hostname, entry->ai_protocol, entry->ai_socktype);
}
return 0;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment