[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

getaddrinfo() problem

Posted on 2004-09-05
5
Medium Priority
?
1,681 Views
Last Modified: 2007-12-19
Here is my code:

      addrhints.ai_family = AF_INET;
      addrhints.ai_socktype = SOCK_STREAM;
      addrhints.ai_protocol = IPPROTO_TCP;
      pres = 0;
      retVal = getaddrinfo(szHost,"80",&addrhints,&pres);

szHost is equal to "bithub.com".  getaddrinfo() is returning 11003 which is WSANO_RECOVERY.  Does anyone know what I'm doing wrong that is causing the error?
Thanks.
0
Comment
Question by:lwinkenb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 11985421
The error code is described as "Nonrecoverable failure in name resolution" (API Ref.: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/getaddrinfo_2.asp). Have you tried to provide an IP address instead of a host name?
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 11986169
no I havent.  Im using this method to get the ip address.  I usually use gethostbyname(), but in msdn, it says that gethostbyname() is depreciated and to use getaddrinfo() instead.
0
 
LVL 7

Accepted Solution

by:
aib_42 earned 1000 total points
ID: 11986172
Try doing a ZeroMemory(&addrhints, sizeof(addrhints)); before setting up ai_family et cetera.
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 11986233
Clearing the memory made it so the function returned successfully.  Yhanks :)
0
 
LVL 7

Expert Comment

by:aib_42
ID: 11993305
For the record, the problem was that the seemingly-unused fields in the struct contained garbage whereas the MSDN documentation states, quote:

ai_addrlen must be zero or a NULL pointer
ai_canonname must be zero or a NULL pointer
ai_addr must be zero or a NULL pointer
ai_next must be zero or a NULL pointer
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question