-static struct addrinfo *udp_resolve_host(URLContext *h,
- const char *hostname, int port,
- int type, int family, int flags)
-{
- struct addrinfo hints = { 0 }, *res = 0;
- int error;
- char sport[16];
- const char *node = 0, *service = "0";
-
- if (port > 0) {
- snprintf(sport, sizeof(sport), "%d", port);
- service = sport;
- }
- if ((hostname) && (hostname[0] != '\0') && (hostname[0] != '?')) {
- node = hostname;
- }
- hints.ai_socktype = type;
- hints.ai_family = family;
- hints.ai_flags = flags;
- if ((error = getaddrinfo(node, service, &hints, &res))) {
- res = NULL;
- av_log(h, AV_LOG_ERROR, "getaddrinfo(%s, %s): %s\n",
- node ? node : "unknown",
- service,
- gai_strerror(error));
- }
-
- return res;
-}
-