Why do something like
Code:
struct addrinto *
host_serv(const char *host, const char *serv, int family, int socktype)
{
int n;
struct addrinfo hints, *res;
bzero(&hints, sizeof(struct addrinfo));
hints.ai_flags = AI_CANONNAME;
hints.ai_famility = family;
hints.ai_socktype = socktype;
if( n = getaddrinfo(host, serv, &hints, &res)) !=0)
return (NULL);
return (res);
}
And then call the function in main() like
Code:
struct addrinfo *ai;
ai = Host_serv(host, NULL, 0, 0);
Why not just call getaddrinfo() directly in main() like
Code:
struct addrinfo hints, *res;
bzero(&hints, sizeof(struct addrinfo));
hints.ai_flags = AI_CANONNAME;
hints.ai_famility = family;
hints.ai_socktype = socktype;
if( n = getaddrinfo(host, serv, &hints, &res) !=0)
return (NULL);