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
4
votes
1 answer

How to use 'getaddrinfo' to choose default free port for all interfaces?

I'm trying to make a server to listen on both IPv4 and IPv6 in dual stack mode. I want the same port number for both IPv4 and IPv6 servers, and I want it to be on a random selection of port (using port "0") when I bind, each server get different…
SHR
  • 7,940
  • 9
  • 38
  • 57
4
votes
1 answer

getaddrinfo - Error: Success

I am very confused. I'm using getaddrinfo to get the address info for a given web host. In this case, I've been using www.cmu.edu. My code was working for a little while, but then it stopped. The odd part is the fact that I'm clearly coming…
user1174511
  • 309
  • 3
  • 5
  • 15
3
votes
4 answers

MongoDB on Vagrant via Port Forwarding issue

I've recently installed mongodb on my CentOS 6 VM running on Vagrant. I added port forwarding to Vagrantfile to forward the mongo port config.vm.forward_port 27017, 127017 I configured mongod to start automatically when the server starts and have…
joseym
  • 1,332
  • 4
  • 20
  • 34
3
votes
1 answer

How to fix getaddrinfo-failure for python on windows

if a start python in a command prompt terminal and try to open some url, I get the following result, despite the name being resolveable through DNS: C:\Windows\system32>nslookup www.google.de Nicht-autorisierende Antwort: Name: …
rumpel
  • 7,870
  • 2
  • 38
  • 39
3
votes
2 answers

Segmentation fault in getaddrinfo()

I am getting segmentation fault in getaddrinfo(). This is the stack trace. Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb7ff4b70 (LWP 26872)] __res_vinit (statp=0xb7ff4df4, preinit=0) at res_init.c:176 176 res_init.c:…
vaibhav3002
  • 255
  • 4
  • 15
3
votes
1 answer

getaddrinfo acting differently on different OS

I'm testing out a error path that requires me to drop a request from getaddrinfo. I set up 2 VMs: RHEL 7.9 Ubuntu 20 The code is the same on both machines, just a call to getaddrinfo for test.com. I blocked all incoming packets to simulate a…
TreeWater
  • 761
  • 6
  • 13
3
votes
1 answer

How to select the interface used to perform a hostname lookup

I am working in an application embedded in a device running Linux and BusyBox. The hardware has 2 communication interfaces: Wi-Fi and 3G. In each connection, the application must try to connect using wi-fi first and, if it fails, the application…
3
votes
1 answer

Getting Error while Web Scraping with python

I am trying to scrape data from espncricinfo website i am requesting pages of each and every match of IPL but getting error sometimes after 10 match or 20 or even 2 sometimes but its not getting complete Below is my code and my error help me out. I…
jv640
  • 41
  • 3
3
votes
0 answers

socket.gaierror: [Errno 10047] getaddrinfo failed

I searched a lot but didn't find a proper solution. Seems like nobody had this problem before. Note my socket.gaierror is [Errno 10047] which means "Address family not supported by protocol family" The error I'm getting is when I try to integrate…
3
votes
1 answer

Why does UDPSocket.send always call getaddrinfo in Ruby?

I just solved a latency issue in our infrastructure that was triggered because this code snippet here triggered a call to getaddrinfo on every run of the code: sock = UDPSocket.open sock.send("#{key}|#{value}", 0, GRAPHITE_SERVER, …
esilver
  • 27,713
  • 23
  • 122
  • 168
3
votes
0 answers

how to bypass GetAddrInfoReqWrap.onlookup error on https.request in nodejs

This is my first time in stackoverflow and I need some help. Here is the problem: I need to get an image from postimg.org with http(s).request() and sent it to the client as dataUrl. Let's say that the image address is:…
Stephanua
  • 31
  • 1
  • 5
3
votes
1 answer

getaddrinfo and INADDR_ANY

Spent a couple of hours searching, still puzzled. From what I've found, INADDR_ANY is meant to specify that the socket will accept connections with any address that is assigned to the server. The following, however, results in the client only being…
3
votes
1 answer

Binding UDP Socket to Cellular IP

I am trying to create an iOS client that sends data to a server on a UDP socket over the device's cellular communication. Following Does IOS support simultaneous wifi and 3g/4g connections? link to iOS Multipath BSD Sockets Test, I've tried…
Cha.OS
  • 88
  • 10
3
votes
0 answers

understanding the protocol family argument of socket() and result list of getaddrinfo()

I had started Network Programming some days ago but there is some confusion that I need to clear. I have not studied much networking or tcp/ip protocol before. Socket function argument: The protocol family argument to socket function denote the set…
rht
  • 106
  • 9
3
votes
2 answers

Explain parameters of getaddrinfo( )

What I don't understand is the **res double pointer, in the man page it states: The hints argument points to an addrinfo structure that specifies criteria for selecting the socket address structures returned in the list pointed to by res. I…
Jordan Davis
  • 1,485
  • 7
  • 21
  • 40