#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
#include "common.h"
return dvbhost;
}
+
+int resolve(struct dvb_host *dvbhost, struct sockaddr_in *server)
+{
+ struct addrinfo *s_addrinfo, addrhints;
+ int res;
+
+ bzero(&addrhints, sizeof(struct addrinfo));
+ addrhints.ai_family = PF_INET;
+ addrhints.ai_socktype = dvbhost->socktype;
+
+ if ((res = getaddrinfo(dvbhost->hostname, dvbhost->port, &addrhints, &s_addrinfo))) {
+ fprintf(stderr,"getaddrinfo: %s\n",gai_strerror(res));
+ return -1;
+ }
+
+ bzero(server, sizeof(struct sockaddr_in));
+ server->sin_family = AF_INET;
+ server->sin_addr.s_addr = ((struct sockaddr_in*)(s_addrinfo->ai_addr))->sin_addr.s_addr;
+ server->sin_port = ((struct sockaddr_in*)(s_addrinfo->ai_addr))->sin_port;
+
+ freeaddrinfo(s_addrinfo);
+
+ return 0;
+}
+