LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-16-2007, 08:06 AM   #1
parthaswathi
LQ Newbie
 
Registered: May 2007
Posts: 2

Rep: Reputation: 0
/etc/hosts and getaddrinfo()


Hi folks,

I am facing problem with getaddrinfo(), which is returning an error saying "Name or service is not known".
Even after giving an IPV6 address in /etc/hosts

The entry in /etc/hosts for the IPV6 address as below

dhoomsolaris fe80::214:4fff:fe61:3da6

The code looks like as below

memset (&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
hints.ai_socktype = SOCK_STREAM;

errnum = getaddrinfo ("dhoomsolaris", SERVER_PORT, &hints, &res);
if (errnum) {
gai_strerror(errnum);
}
Please help in this, I will appreciate the same.

Regards,
Swathi

Last edited by parthaswathi; 05-16-2007 at 10:44 PM.
 
Old 05-16-2007, 05:13 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
This is very vague… What did you use for “hints.ai_flags”? Specifically, what is “hints.ai_flags & AI_NUMERICSERV”?

A short sample of code that exhibits the failure would prove helpful (remember to use [code] and [/code]).
 
Old 05-16-2007, 10:48 PM   #3
parthaswathi
LQ Newbie
 
Registered: May 2007
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by osor
This is very vague… What did you use for “hints.ai_flags”? Specifically, what is “hints.ai_flags & AI_NUMERICSERV”?

A short sample of code that exhibits the failure would prove helpful (remember to use [code] and [/code]).
Sorry for giving an incomplete information.

I have edited the question by providing enough information, can you please look into that and help me the same.


Regards,
Partha
 
Old 05-17-2007, 03:48 PM   #4
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
First off, it still isn’t a very complete sample of code (For example, if you get an error, gai_strerror(errnum) will show you nothing. Additionally, you never showed us the definition of SERVER_PORT. Additionally, you didn’t use [code] tags!).

Nevertheless, I think I can help you . It seems to me the error is caused by the format of your /etc/hosts entry. The entry format is supposed to be (at least on linux, *BSD, and Mac):
Code:
ip_address canonical_hostname aliases
For example:
Code:
::1 localhost loopback
So your entry should be changed to something like:
Code:
fe80::214:4fff:fe61:3da6 dhoomsolaris
If it is still failing, you might have a problem with your numerical service (IIRC, you were previously using a numerical service). To circumvent this, you tell the resolver explicitly that you don’t need your service to be translated numerically. E.g.,
Code:
#define SERVER_PORT "80"

	memset (&hints, 0, sizeof(hints));
	hints.ai_family = AF_UNSPEC;
	hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG | AI_NUMERICSERV;
	hints.ai_socktype = SOCK_STREAM;

	int errnum = getaddrinfo ("dhoomsolaris", SERVER_PORT, &hints, &res);
	if (errnum)
		fprintf(stderr, "Name Resolution Failure: %s\n", gai_strerror(errnum));
 
  


Reply

Tags
getaddrinfo



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/etc/hosts.deny/hosts.allow have no effect on sshd access bganesh Linux - Security 4 05-04-2006 08:06 PM
External Hosts Resolve but Local Hosts Do Not kjm9 Linux - Networking 7 11-19-2005 03:51 PM
"getaddrinfo failed: Temporary failure in name resolution" SammyK Linux - Networking 3 03-09-2005 11:43 AM
Sockets : Getaddrinfo call fails abrb220 Programming 2 06-06-2004 11:26 PM
Adding shell commands to hosts.deny and hosts.allow ridertech Linux - Security 3 12-29-2003 03:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration