Uniform getaddrinfo() on WIN32 or POSIX, because MinGW now supports it
This commit is contained in:
parent
9c63ffa546
commit
b1e0bde529
23
src/listen.c
23
src/listen.c
@ -213,7 +213,6 @@ static bool
|
|||||||
listen_add_host(const char *hostname, unsigned port, GError **error)
|
listen_add_host(const char *hostname, unsigned port, GError **error)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_TCP
|
#ifdef HAVE_TCP
|
||||||
#ifndef WIN32
|
|
||||||
struct addrinfo hints, *ai, *i;
|
struct addrinfo hints, *ai, *i;
|
||||||
char service[20];
|
char service[20];
|
||||||
int ret;
|
int ret;
|
||||||
@ -250,28 +249,6 @@ listen_add_host(const char *hostname, unsigned port, GError **error)
|
|||||||
freeaddrinfo(ai);
|
freeaddrinfo(ai);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#else /* WIN32 */
|
|
||||||
const struct hostent *he;
|
|
||||||
|
|
||||||
g_debug("binding to address for %s", hostname);
|
|
||||||
|
|
||||||
he = gethostbyname(hostname);
|
|
||||||
if (he == NULL) {
|
|
||||||
g_set_error(error, listen_quark(), 0,
|
|
||||||
"Failed to look up host \"%s\"", hostname);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (he->h_addrtype != AF_INET) {
|
|
||||||
g_set_error(error, listen_quark(), 0,
|
|
||||||
"IPv4 address expected for host \"%s\"",
|
|
||||||
hostname);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return listen_add_address(AF_INET, he->h_addr, he->h_length,
|
|
||||||
error);
|
|
||||||
#endif /* !WIN32 */
|
|
||||||
#else /* HAVE_TCP */
|
#else /* HAVE_TCP */
|
||||||
|
|
||||||
(void)hostname;
|
(void)hostname;
|
||||||
|
Loading…
Reference in New Issue
Block a user