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
0
votes
2 answers

How can we send data to ipv4 and ipv6 google interface using non connected socket udp in C?

I'm trying to send some random datagram to host www.google.fr to both ipv4 and ipv6 interfaces, this work fine for ipv4 but not for ipv6. I wanted to do it with a single not-connected socket via UDP protocol. I did something using getaddrinfo, and…
Omar Aldakar
  • 505
  • 2
  • 8
0
votes
1 answer

Usage of Unix getaddrinfo C function to start set the server

I am building a client-server application in C with the source code taken from the book Advanced Programming in Unix Environment. In the server it is doing the following: struct addrinfo hint; memset(&hint, 0, sizeof(hint)); hint.ai_flags =…
roschach
  • 8,390
  • 14
  • 74
  • 124
0
votes
0 answers

How to filter packets sent by dns.lookup in Wireshark on Windows?

To give some context: we're monitoring the network connectivity in our app by calling nodeJS dsn.lookup within an interval. Some of our users are facing issues with this technique. So I'd like to inspect what's going on when degrading the network…
Eturcim
  • 798
  • 8
  • 26
0
votes
1 answer

Socket address showing 0.0.0.0, causing failure to send message

I've been working from Beejs Network examples, introducing a few customizations. In particular, I'm trying to use a single structure to store the necessary information related to communications/sockets. I think I'm having trouble populating an…
ThatsRightJack
  • 721
  • 6
  • 29
0
votes
3 answers

Node.js/ webpack/ getaddrinfo looking for internet when not needed, why?

I've got an issue with a machine that's supposed to be able to run offline. I can pull the cable after my application is running, but during unplugged start I get the following error: May 6 23:04:50 myco serve[4121]: (node:4121)…
0
votes
0 answers

Python paramiko socket.gaierror: [Errno 11001] getaddrinfo failed

I have the code below which results in: File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\socket.py", line 745, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror:…
Diegoctn
  • 55
  • 1
  • 10
0
votes
0 answers

Does the order of declaring parameters for getaddrinfo matter?

I am writing a small server-client program using getaddrinfo(). while #include #include #include #include #include char port[] = "1933"; char ip[] = "192.168.178.26"; int main() { //…
hurm
  • 11
  • 2
0
votes
1 answer

Hostnames resolution fails with "unknown host" error for hostnames containing utf-8 characters

I am trying to ping a hostname "win-2k12r2-addc.阿伯测阿伯测ad.hai.com" from a linux client. I see that DNS requests go over the wire with hostname being sent in utf-8 format and i get a response from the DNS server also with the correct IP address. But…
Vignesh
  • 31
  • 5
0
votes
0 answers

getaddrinfo ENOTFOUND error

I had a perfectly running nodejs server on an EC2 instance of Amazon AWS. By mistake, I missed a couple of payments and the service was halted. When I paid and brought the account up to date, I found the server was back in place and was already…
Vaibhav Gupta
  • 79
  • 1
  • 6
0
votes
1 answer

Im wondering why I get a getaddrinfo error on my rasberry pi

Im working on a self watering plant system. Link here https://www.hackster.io/demirhanaydin/waterpi-houseplant-remote-watering-and-monitoring-system-340400. I followed all the steps and have modified the code slightly for my lcd to work. I keep…
0
votes
1 answer

C getaddrinfo() not resolving name

I have a program (written in C) that uses getaddrinfo() and its first parameter is the host name that I want it to get address information about, let's say it is "domain". In my /etc/hosts file on the same machine I can see that "domain" is…
LebowskiT1000
  • 21
  • 1
  • 5
0
votes
0 answers

How does getaddrinfo work with a dualstack source?

Some background: We are running go based applications on ubuntu servers on AWS. Recently we started having DNS round-robin issues where one of the load balancers (ELB) will end up handling a large portion of the traffic(~ 5:1) and thus overloading…
rlhh
  • 893
  • 3
  • 17
  • 32
0
votes
1 answer

getaddrinfo error: nodename nor servname provided, or not known

When I tryed to get IP address for DNS name with getaddrinfo I got the following error getaddrinfo error: nodename nor servname provided, or not known What does this error means? Is it possible that getaddrinfo can't resole the DNS name? But…
Vlad
  • 2,090
  • 3
  • 21
  • 37
0
votes
1 answer

getaddrinfo - results differ for numeric vs. named service

I have a question about the behavior of getaddrinfo(), which seems to depend on how the service argument is specified. Specifying the service as a name causes getaddrinfo() to use getservbyname() to query the /etc/services database, but specifying…
Jon
  • 63
  • 7
0
votes
0 answers

Wampserver gives this error whan i open my webpage. getaddrinfo failed: The requested name is valid, but no data of the requested type was found

Wamp server dont connects to databse. Here is my connection code. It works okay on PC at home but Fails on Laptop on job. The thing is i cant find answer for this issue. Laptop gets DNS adresses automaticlly. $db =…
Wkyp
  • 1
  • 3