Questions tagged [getaddrinfo]

`getaddrinfo(3)` provides network address and service translation.

From the man page:

Name

getaddrinfo, freeaddrinfo, gai_strerror - network address and service translation

Synopsis

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>

int getaddrinfo(const char *node, const char *service,
                const struct addrinfo *hints,
                struct addrinfo **res);

void freeaddrinfo(struct addrinfo *res);

const char *gai_strerror(int errcode);

Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

getaddrinfo(), freeaddrinfo(), gai_strerror():
    _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE 

Description

Given node and service, which identify an Internet host and a service, getaddrinfo() returns one or more addrinfo structures, each of which contains an Internet address that can be specified in a call to bind(2) or connect(2). The getaddrinfo() function combines the functionality provided by the getservbyname(3) and getservbyport(3) functions into a single interface, but unlike the latter functions, getaddrinfo() is reentrant and allows programs to eliminate IPv4-versus-IPv6 dependencies.

252 questions
3
votes
1 answer

getaddrinfo isn't resolving hostnames

nc -zv cms-01 5061 Fails with: nc: getaddrinfo: No address associated with hostname But ping/dig work just fine. You can see the different most with getent: # getent hosts cms-01 172.17.2.108 cms-01.docker But with "ahosts" instead of…
mpeters
  • 4,737
  • 3
  • 27
  • 41
3
votes
1 answer

gethostbyname/getaddrinfo keeps failing, even when internet connection is up

Background We have a small headless box running Linux kernel 2.6.35 and some variant of Open Embedded distribution on ARM hardware. As far as we can tell we are using glibc 2.10.1. The box has an unconnect ethernet and a serial attached GSM/3G…
Nicolai Henriksen
  • 1,324
  • 1
  • 13
  • 37
3
votes
2 answers

Select a listening addresses for IPv6 server (Dual stack)

It will be seem a weird question to some. but I've searched and didn't find any answer. When I want a dual stack server, I need to listen on INADDR_ANY for IPv4 and to in6addr_any for IPv6. If I have more than one network card then I need to choose…
SHR
  • 7,940
  • 9
  • 38
  • 57
3
votes
1 answer

Bogus IP Address from getaddrinfo & inet_ntop

I've been using getaddrinfo for looking up socket addresses for basic socket commands. Recently, though, the addresses it returns to me are for bogus IP addresses, which I have found using inet_ntop. I've tried my code, as well as that provided in…
Xymostech
  • 9,710
  • 3
  • 34
  • 44
3
votes
2 answers

"getaddrinfo() argument 1 must be string or None" error starting dev_appserver.py on Linux

I'm getting re-started with App Engine after not having used it in a while. I'm using the 64-bit Linux Go runtime, version 1.8.1. I believe I'm following the steps from the documentation correctly, and I believe I'm doing what's worked correctly in…
Darshan Rivka Whittle
  • 32,989
  • 7
  • 91
  • 109
3
votes
2 answers

.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:644:in `initialize': No such file or directory - getaddrinfo (Errno::ENOENT)

I got this error when I tried to run: rake db:migrate, rake schema:load and rails s. The application I git cloned from Bitbucket is unusable and the client is unable to help. I have reinstalled ruby and gemset and it didn't work. I have no idea how…
ruby_object
  • 1,229
  • 1
  • 12
  • 30
3
votes
1 answer

getaddrinfo with localhost: different behaviour when statically linked or not on same system

I have a small c program which basically calls getaddrinfo. According to /etc/hosts localhost can be resolved to "127.0.0.1" and "::1". Now when running the program the output depends on whether I compiled and linked using: gcc -static test.c $…
user1240076
  • 183
  • 1
  • 2
  • 10
3
votes
1 answer

getaddrinfo for ipv6 link local

I tried to get the address info in to structred addrinfo **result . but I get the below error for the code error in getaddrinfo: Address family for hostname not supported code error = getaddrinfo("fe80::4e80:93ff:fe33:13ff%wlan0", NULL, NULL,…
indra
  • 832
  • 4
  • 17
  • 33
3
votes
1 answer

Paypal IPN: random " php_network_getaddresses: getaddrinfo failed: Name or service not known (0)" error

While using the following Paypal IPN code I sometimes gets a "getaddrinfo failed" error and my script (to update a mySQL database via PHP) is not executed. THE CODE // read post from PayPal system and add 'cmd' $postvars = array(); while (list…
Denis
  • 31
  • 1
  • 2
3
votes
0 answers

Python:SMTP init method hangs when used in try:except block

I am trying to send some backtraces via email for which i am using the python SMTP lib. My code looks like this def send_email_thread(from_addr, to_addr, message): server = smtplib.SMTP("smtp.googlemail.com", 587) server.ehlo() …
auny
  • 1,920
  • 4
  • 20
  • 37
3
votes
1 answer

how to get wildcard address using getaddrinfo

Cross post on : http://www.perlmonks.org/?node_id=988678 I am new to perl. I am trying to fetch all the wildcard interfaces using getaddrinfo (I am using Socket6 (IO:Socket:IP somehow didn't work on my Windows box)), like: use Socket; use…
Sushant
  • 379
  • 3
  • 14
2
votes
1 answer

IOError: [Errno socket error] [Errno 11004] getaddrinfo failed

I am beginner python prorammer. With 2.7.2, Windows 7, built-in interpreter, and three libraries. I am trying to do this, with error. I appreciate any help? import os import urllib import socket DISNEY_URL =…
Nate Anderson
  • 18,334
  • 18
  • 100
  • 135
2
votes
2 answers

getaddrinfo doesn't get ipv6 address

I am trying to get both ipv4 and ipv6 adresses and connect to server with them but i can only connect with ipv4 address. It is a standard code actually. both ipv4 and ipv6 addresses are in /etc/hosts 192.155.112.18 hostname.site…
Brknl
  • 97
  • 3
  • 9
2
votes
3 answers

Unix sockets with getaddrinfo() in C

Does anyone know if it's possible to use getaddrinfo with unix sockets in C (AF_UNIX). I've tried a couple of things but I can't make it work. This is basically what I'm trying: struct addrinfo hints, *res; memset(&hints, 0,…
esteban
  • 53
  • 2
  • 7
2
votes
2 answers

getaddrinfo() fails when attempting to download a stream

I'm trying to download a few seconds from a livestream using sockets. #include #include #include #include /* close() */ #include #include int main(void) { int sock; char…
Xantium
  • 11,201
  • 10
  • 62
  • 89