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
1
vote
4 answers

WSAGetLastError() returns 122

Well.. I am not really sure what that means, but my systems runs and runs and runs without crying for insufficient memeory... I guess it has to do with the system error 122, because there is no 122 in the winsock error codes (MSDN)... Anyone got a…
Juarrow
  • 2,232
  • 5
  • 42
  • 61
1
vote
2 answers

Cannot start apache2 in WSL

I'm getting the following error when I try to start apache2 from WSL: ➜ ~ sudo service apache2 start * Starting Apache httpd web server apache2 * * The apache2 configtest failed. Output of config test was: apache2:…
1
vote
0 answers

socket.getaddrinfo doesn't return my IPV6 address with AF_INET6 or "0" as arguments

I'm using the following Python code to fetch ipv4 and ipv6 addresses information (according to millions of tutorials i went through including https://docs.python.org/3.5/library/socket.html), but i receive only the ipv4 info. My ipv6 connection is…
1
vote
1 answer

How to get zone-id from interface index for send with ipv6 addr?

I have to get zone id from network interface index for send data with ipv6 addr. Normally interface index number or interface name is used for zone id with ipv6 addr. But someone told me interface name or index number is not zone id. so... is there…
1
vote
1 answer

Why must the struct addrinfo be partially filled out before using getaddrinfo() on it?

I have been following along Beej's Guide to Network Programming and am having trouble understanding why we must fill in some of the fields of the struct addrinfo before calling getaddrinfo()? Also, why does it return a pointer to a list of multiple…
user6475544
1
vote
1 answer

How to choose a server socket address using getaddrinfo?

I would like to create a TCP server application which lets the user choose the local address that is used in the bind call. The user may provide a textual representation of a host name or IP address, so I thought of using the getaddrinfo function to…
purefanatic
  • 933
  • 2
  • 8
  • 23
1
vote
1 answer

Bluemix NodeJS ENOTFOUND

I have a bluemix node js application which communicates with a server. I have test and production environment. On the development environment we communicate to the test server, and I get a node js error. When I change the server URL to the…
David K.
  • 21
  • 1
  • 4
1
vote
2 answers

How do I store an IPv6 address from getaddrinfo into a character array?

I have an addrinfo structure that I get by calling the getaddrinfo() function with the following parameters: getaddrinfo(address, NULL, &hints, &res) I need to store the IPv6 address in binary form and print it in hexadecimal form. My question is,…
Kuyss
  • 39
  • 2
  • 7
1
vote
1 answer

How to get html code using python sockets

So I'm trying to get the source code of google using only python sockets and not any other libraries such as urllib. I don't understand why my GET request isn't working, I tried all possible methods. This is the code I have, it's pretty small and I…
demogorgon
  • 49
  • 1
  • 9
1
vote
0 answers

Windows7: getaddrinfo returning "No such host is known" for [::1]

I'm working on modifications to my code to support dual stack environments on Windows 7 et. al. The code uses ActiveMQ-CPP (3.8.4). I've set this up to use a connection to the broker on URI "tcp://[::1]:61616". I've already found I need to…
wdtj
  • 4,554
  • 3
  • 17
  • 20
1
vote
0 answers

Resolve FQDN but not necessarily canonical name with getaddrinfo()

Good evening, folks. Is it possible to use getaddrinfo()/getnameinfo() to resolve non-FQDN names to their FQDN versions, but without necessarily going all the way down to the canonical name, in a way similar to that of gethostbyname()? To clarify my…
Paulo1205
  • 918
  • 4
  • 9
1
vote
1 answer

Resolve and bind to IPv6 address

I wrote a program that resolves an address or hostname and then attempts to bind to that address in listen(2) mode. For some strange reason I am unable to use IPv6 addresses, the program simply fails with "Invalid argument" after calling bind(2).…
antagon
  • 119
  • 8
1
vote
1 answer

getaddrinfo() API with systemd

I am facing problem while querying DNS using getaddrinfo() API under a process initiated by systemd. Despite having nameserver entry in /etc/resolv.conf, the query fails to resolve. After few system call traces, it is found that the problem is due…
nkumar
  • 51
  • 2
1
vote
1 answer

I'm getting "Unable to find the socket transport 'http'" error suddenly. It was working fine until we switched networks

After a network switch, parts of my program that send data to other servers are no longer working. I tried the following code: \n"; …
Mike N
  • 13
  • 1
  • 9
1
vote
2 answers

service to port number like getaddrinfo

In C you can use a service name to get the port number when using getaddrinfo, like this: getaddrinfo("stackoverflow.com", "http", &hints, &results); This will assign 80 (big endian) to the first two bytes (uint16_t) of results->ai_addr. Is there…
Horse SMith
  • 1,003
  • 2
  • 12
  • 25