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

Server-client sockets : freeaddrinfo(3) placement

I have to test this passive tcp server on loopback interface. Ip and port are given by command line and parsed with getopt. Then it sets and binds a TCP socket with getaddrinfo(3) and starts busy waiting. Server: #include "server_utils.h" #define…
Fabio Carello
  • 1,062
  • 3
  • 12
  • 30
1
vote
1 answer

Get size of HTTP response in C

I'm building a fuzzer (web application security tool) and I'm having some trouble building the proxy server. Below is my code for a function that takes in a char* http message, converts a host name in ascii to the IP address, and then establishes a…
barndog
  • 6,975
  • 8
  • 53
  • 105
1
vote
1 answer

get ipv6 address from addrinfo struct in windows xp

how is it possible to get an ipv6 address from a addrinfo struct under windows xp? is there any other possibility than WSAAddressToString (has anyone ever successfully used that one?) ? getaddrinfo(server_ip, port, &hints, &result) addr = (struct…
Mirko
  • 67
  • 5
1
vote
3 answers

Will getaddrinfo() return IPv6 addresses first?

I want to read all the addresses(IPv4 and IPv6) using getaddrinfo(). My question is whether getaddrinfo() returns IPv6 address followed by IPv4 in the list. Assuming that I'm passing AF_UNSPEC to getaddrinfo() and using dual stack.
Chandu
  • 1,837
  • 7
  • 30
  • 51
1
vote
1 answer

Determine which of the addrinfo structures returned by getaddrinfo belongs to the current machine

I call getaddrinfo. It returns a list of matching addresses. One of them belongs to the machine from which the call was made. How do I determine which one it is? If there is no way to do so, is there anything else I can do to reliably and portably…
user500944
1
vote
1 answer

Safari and getaddrinfo interposing

I've written a small dynamic library that interposes calls to getaddrinfo and connect. I insert this library using DYLD_INSERT_LIBRARIES on Firefox and Safari to hijack requests for www.apple.com and send them to www.microsoft.com. The code works…
0
votes
1 answer

getaddrinfo() could not be resolved winsock

I'm having problems getting winsock to work, I'm just baffled and don't really know what to try next. the getaddrinfo(NULL) is just there to show that it recognizes what arguments getaddrinfo should have but it still says it can't resolve it.. When…
Dron
  • 47
  • 2
  • 8
0
votes
2 answers

getaddrinfo() returns 127.0.0.1 for remote host

I have an application which uses getaddrinfo() to translate from the hostname of a PC in a Windows Workgroup to the IPV4 address for that PC on the LAN. (Note, I don't mean getting the address of the PC the code is running on, I mean the address of…
pnswdv
  • 181
  • 2
  • 8
0
votes
1 answer

How to handle inet_ntop() failure?

First of all, my code example: cout << "bla1" << endl; struct addrinfo hints, *info; int status; memset(&hints, 0, sizeof hints); char ip4[INET_ADDRSTRLEN]; char ip6[INET6_ADDRSTRLEN]; hints.ai_family = AF_INET; hints.ai_socktype =…
milanseitler
  • 765
  • 1
  • 7
  • 21
0
votes
1 answer

Conceptual query with Getaddrinfo method

When using the getaddrinfo method, I'm providing an IP address and the port number. I'm getting a linked list in the out variable. It works fine. But I have a conceptual doubt here. When i am giving both the IP address and port, how is it there are…
Nanda
  • 1,038
  • 2
  • 16
  • 33
0
votes
1 answer

"npm install" command gives "EAI_AGAIN" error with "getaddrinfo" syscall

I'm trying to run the "npm install" command in my react project on windows, this was working a few days ago, but now I keep getting the following error message: npm WARN config global `--global`, `--local` are deprecated. Use `--location=global`…
RGVylar
  • 1
  • 3
0
votes
0 answers

python-hpilo functions giving error: socket.gaierror: [Errno 11001] getaddrinfo failed

I am trying to use HP iLO automation from python. I am following https://seveas.github.io/python-hpilo/ for my reference. I have installed python-hpilo and in my python file I have created an instance of ilo ilo = hpilo.Ilo('ip-range', 'Username',…
richa verma
  • 247
  • 2
  • 13
0
votes
0 answers

GaiException while resolving domain on AOSP platform app

I added an app to AOSP and it has the "platform" certificate. When I just install it on my device it resolves the domain just fine, but as a system app I get an GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with…
0
votes
1 answer

Is it possible for getaddrinfo to return 0 (success) but found no addresses (`addrinfo*` is null)

I see in the man page, there is EAI_NODATA. Does that refer to the case above where there are no addresses found? Meaning getaddrinfo returns 0 implies at least one address was found?
bun9
  • 161
  • 8
0
votes
1 answer

"getaddrinfo() argument 1 must be string or None " error after call this code

import imaplib, email with open('Accounts.txt', 'r') as f: data = f.readline()[1:] user, password = data.split(':') with open(b'serverimap.txt', 'r') as good: serverss = good.readlines() …