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
3 answers

c++ getaddrinfo doesnt process for big URL's

C++ Sockets. Getting information from a website. I am trying to read content from web using sockets. using the following code. int status = getaddrinfo(l_url.c_str(), "http", &l_address, &l_addr_ll); if (status != 0 ){ printf("\n *****…
kris123456
  • 501
  • 1
  • 5
  • 15
0
votes
3 answers

Why is addrinfo loop needed?

Suppose we have a pure IPv6 network. A socket app uses getaddrinfo to find HOST1 by its hostname, and gets one of HOST1's IP addresses as the first response. Why should it loop on the returned addresses? Isn't it the responsibilty of the routers…
Joseph
  • 11
0
votes
2 answers

how can I make getaddrinfo return only one result?

I want to use getaddrinfo() but get only the first result. more specifically, I want the function to first scan the hosts file and fetch the first result found, and only if not found in hosts I want to query the dns server. is it possible? thanks.
Ronen Ness
  • 9,923
  • 4
  • 33
  • 50
0
votes
1 answer

getaddrinfo stucks forever when linked with sqlite3

I have a program which requires a DNS query and a sqlite3 DB connection. I have determined that it hangs indefinitely at a getaddrinfo() call. So I created a test program (from busybox's nslookup.c) with only this call. When I do not link the…
OziMan
  • 3
  • 4
0
votes
2 answers

Using Getaddrinfo() and SendTo() on Socket UDP fails - Segmentation fault (core dumped)

After I start using getaddrinfo() to retrieve dynamic IP addresses, the sendTo() of my socket no longer works and returns error "Segmentation fault (core dumped)". Why is that happening, is there any initialization or memory allocation missing in my…
user2212304
  • 13
  • 1
  • 5
0
votes
1 answer

getaddrinfo Removes last character

int print_socket_info(int sock_fd, struct sockaddr_in *sin, short protocol){ char dbg[INET_ADDRSTRLEN]; char *famstr; inet_ntop(protocol, &(sin->sin_addr), dbg, INET_ADDRSTRLEN); printf("============ SOCKET INFORMATION…
i41
  • 311
  • 2
  • 9
0
votes
1 answer

getaddrinfo 11004 and python's httplib

I'm trying to get the rendered markup for http://www.epicurious.com/recipes/food/reviews/Breaded-Chicken-Cutlets-aka-Grandma-Jodys-Chicken-51114400; in theory the very same markup given by the 'View Page Source' menu option in Firefox. I'm using a…
0
votes
0 answers

why does xcode 4.4.1 give error while trying to use getaddrinfo ?

I am using xcode 4.4.1 to do socket programming in c++. I think i have included required header file. But i still get error saying: " No matching function for call to 'getaddrinfo' ". There was duplicate question here The header files that i have…
solti
  • 4,339
  • 3
  • 31
  • 51
-1
votes
2 answers

Why does getaddrinfo() return a value in the inputs part of the function?

The definition of getaddrinfo() is: int getaddrinfo(const char *node, // e.g. "www.example.com" or IP const char *service, // e.g. "http" or port number const struct addrinfo *hints, struct…
Zakoff
  • 12,665
  • 5
  • 22
  • 35
-1
votes
1 answer

Built exe using Cygwin on Win10, but getting errors regarding kernel32.dll

I'm new to Cygwin. I installed it today (latest release downloaded from their web site), and built a program I've been working on, one which, years ago, was built for Windows using Cygwin by a different developer - Blitzed IRC Trivia (develop…
Andy Alt
  • 297
  • 2
  • 12
-1
votes
1 answer

ZendFramework error: getaddrinfo failed: nodename nor servname provided

I install MySQL, php with nginx on mac os x. This is the first time that I install on a Mac, so far I've used linux. I got this error when i try to run my zend application. I tried that instead of localhost enter ip adress and 127.0.0.1, But i get…
-1
votes
2 answers

Socket Programming using IPv6 where client and server program resides on different machines

I am trying to create a client/server program(both programs lies on different machine and not on localhost) in C but the protocol used is IPv6 only. when i run the client,it pauses for sometime at the connect() and then fails.Why connect() is…
Shikhar Deep
  • 253
  • 2
  • 8
  • 19
1 2 3
16
17