[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

the question about getaddinfo

Qq Zz

5/14/2009 8:30:00 AM

I use getaddinfo to get A machine's hostname,
in B machine,the result is correct.
but in A machine,the result is just A machine's name
I use nslookup,the result is also correct.
who can tell me why in A machineï¼?the result is wrong?
--
Posted via http://www.ruby-....

9 Answers

Vladimir Fekete

5/14/2009 8:50:00 AM

0

Hi,
approx. 3-5 months ago I had similar problem. The guy who helped tried to
help mes said that it works for him. Then he realized that he uses a newes
version of ruby (1.9.something at that time). So my first suggestion would
be to check (or to write) what version of ruby are you using.
I solved the problem using external command (host). I hope it helped a
bit.

Cheers,

V.

On Thu, May 14, 2009 at 05:29:50PM +0900, Qq Zz wrote:
> I use getaddinfo to get A machine's hostname,
> in B machine,the result is correct.
> but in A machine,the result is just A machine's name
> I use nslookup,the result is also correct.
> who can tell me why in A machine???the result is wrong?
> --
> Posted via http://www.ruby-....
>
>

Brian Candler

5/14/2009 10:18:00 AM

0

Qq Zz wrote:
> I use getaddinfo to get A machine's hostname,
> in B machine,the result is correct.
> but in A machine,the result is just A machine's name
> I use nslookup,the result is also correct.
> who can tell me why in A machineï¼?the result is wrong?

You don't even say what platform you're on. If you're on a Unix-like
platform, then maybe you have something like

1.2.3.4 machineA machineA.com

in /etc/hosts.
--
Posted via http://www.ruby-....

Bill Kelly

5/14/2009 10:20:00 AM

0


From: "Qq Zz" <zq1956@sina.com.cn>
>
> I use getaddinfo to get A machine's hostname,
> in B machine,the result is correct.
> but in A machine,the result is just A machine's name
> I use nslookup,the result is also correct.
> who can tell me why in A machineï¼?the result is wrong?

I ran into something similar awhile back:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-...

This is what I now use:

ip = "208.77.188.166"
result = Socket.getnameinfo( Socket.pack_sockaddr_in(0, ip) )
hostname = result ? result.first : ip


Hope this helps,

Bill



Qq Zz

5/14/2009 10:47:00 AM

0

Brian Candler wrote:
> Qq Zz wrote:
>> I use getaddinfo to get A machine's hostname,
>> in B machine,the result is correct.
>> but in A machine,the result is just A machine's name
>> I use nslookup,the result is also correct.
>> who can tell me why in A machineï¼?the result is wrong?
>
> You don't even say what platform you're on. If you're on a Unix-like
> platform, then maybe you have something like
>
> 1.2.3.4 machineA machineA.com
>
> in /etc/hosts.

no,windows vista


--
Posted via http://www.ruby-....

Qq Zz

5/14/2009 10:49:00 AM

0

Bill Kelly wrote:
> From: "Qq Zz" <zq1956@sina.com.cn>
>>
>> I use getaddinfo to get A machine's hostname,
>> in B machine,the result is correct.
>> but in A machine,the result is just A machine's name
>> I use nslookup,the result is also correct.
>> who can tell me why in A machineï¼?the result is wrong?
>
> I ran into something similar awhile back:
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-...
>
> This is what I now use:
>
> ip = "208.77.188.166"
> result = Socket.getnameinfo( Socket.pack_sockaddr_in(0, ip) )
> hostname = result ? result.first : ip
>
>
> Hope this helps,
>
> Bill

the response is: address family for hostname not supported

oh my god!!!
--
Posted via http://www.ruby-....

Bill Kelly

5/14/2009 12:48:00 PM

0


From: "Qq Zz" <zq1956@sina.com.cn>
>
> the response is: address family for hostname not supported

Hmm. I too get that error on Windows:

ruby -v -rsocket -e "p Socket.getnameinfo(Socket.pack_sockaddr_in(0, '208.77.188.166'))"
ruby 1.8.4 (2005-12-24) [i386-mswin32]
-e:1:in `getnameinfo': getnameinfo: address family for hostname not supported. (SocketError)
from -e:1

ruby19 -v -rsocket -e "p Socket.getnameinfo(Socket.pack_sockaddr_in(0, '208.77.188.166'))"
ruby 1.9.1p129 (2009-05-12) [i386-mswin32_71]
-e:1:in `getnameinfo': getnameinfo: The requested name is valid and was found in the database,
but it does not have the correct associated data being resolved for. (SocketError)
from -e:1:in `<main>'


However it works on Linux:

ruby -v -rsocket -e "p Socket.getnameinfo(Socket.pack_sockaddr_in(0, '208.77.188.166'))"
ruby 1.8.6 (2008-07-17 patchlevel 279) [x86_64-linux]
["www.example.com", "0"]


Hmm... dunno... :(


Regards,

Bill



Qq Zz

5/15/2009 4:12:00 AM

0

Vladimir Fekete wrote:
> Hi,
> approx. 3-5 months ago I had similar problem. The guy who helped tried
> to
> help mes said that it works for him. Then he realized that he uses a
> newes
> version of ruby (1.9.something at that time). So my first suggestion
> would
> be to check (or to write) what version of ruby are you using.
> I solved the problem using external command (host). I hope it helped a
> bit.
>
> Cheers,
>
> V.

1.9.1 not work
host? in windows?
--
Posted via http://www.ruby-....

DanielSan

1/31/2012 11:16:00 AM

0

On 1/31/2012 2:37 AM, NoBody wrote:
> On Mon, 30 Jan 2012 02:52:12 -0800, DanielSan
> <danielsan1977@gmail.com> wrote:
>
>> On 1/30/2012 2:46 AM, NoBody wrote:
>>> On Fri, 27 Jan 2012 07:56:04 -0800, DanielSan
>>> <danielsan1977@gmail.com> wrote:
>>>
>>>> On 1/27/2012 2:22 AM, NoBody wrote:
>>>>> On Thu, 26 Jan 2012 02:54:58 -0800, DanielSan
>>>>> <danielsan1977@gmail.com> wrote:
>>>>>
>>>>>> On 1/26/2012 2:49 AM, NoBody wrote:
>>>>>>> On Wed, 25 Jan 2012 06:45:58 -0800, DanielSan
>>>>>>> <danielsan1977@gmail.com> wrote:
>>>>>>>
>>>>>>>> On 1/25/2012 3:04 AM, NoBody wrote:
>>>>>>>>> On Tue, 24 Jan 2012 06:12:10 -0500, NoBody<NoBody@nowhere.com> wrote:
>>>>>>>>>
>>>>>>>>>> On Mon, 23 Jan 2012 03:00:35 -0800, DanielSan
>>>>>>>>>> <danielsan1977@gmail.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> On 1/23/2012 2:57 AM, NoBody wrote:
>>>>>>>>>>>> On Sun, 22 Jan 2012 21:46:42 -0700, Yoorghis@Jurgis.net wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> On Sun, 22 Jan 2012 18:19:42 -0800 (PST), Jim Austin
>>>>>>>>>>>>> <bja@ix.netcom.com> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I was glad that Obama took out bin Laden. However, if Obama's policies
>>>>>>>>>>>>>> had been in effect during the Bush administration, bin Laden would
>>>>>>>>>>>>>> still be at large. Indeed, had word gotten out that Obama refused to
>>>>>>>>>>>>>> take out bin Laden when the opportunity arose, his reelection chances
>>>>>>>>>>>>>> would have gone down the toilet.
>>>>>>>>>>>>>
>>>>>>>>>>>>> You forget that any policies under bush were ENTIRELY republican.
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Yet you hold Republicans (while in the minority) responsible for the
>>>>>>>>>>>> Dems spending. Oddly the reverse doesn't seem to apply in your tiny
>>>>>>>>>>>> mind.
>>>>>>>>>>>
>>>>>>>>>>> You seem to forget the record number of filibusters and obstructionism
>>>>>>>>>>> that Republicans have done since they've been in the minority.
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> And the Dems did the same when they were in the minority -- a
>>>>>>>>>> distinction without a difference.
>>>>>>>>
>>>>>>>> Huge difference. But I don't expect you to realize why or how. You
>>>>>>>> haven't been told that by your handlers.
>>>>>>>
>>>>>>> A distinction without a difference (your fantasies not withstanding).
>>>>>>>
>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> But, please. Cite Democratic spending policy and how much they
>>>>>>>>>>> contribute to the current situation.
>>>>>>>>>>
>>>>>>>>>> You have looked at the national debt numbers under the Dems and Obama
>>>>>>>>>> right?
>>>>>>>>
>>>>>>>> Yes. And have you looked at what policies make up those debt numbers?
>>>>>>>
>>>>>>> Bills signed by Obama and money spent by Obama is his responsiblity
>>>>>>> and policies.
>>>>>>>
>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Use as much space as necessary.
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> Obamas "policies" were controlled (and still are) by Republican
>>>>>>>>>>>>> obstruction and filibuster
>>>>>>>>>>>>
>>>>>>>>>>>> The Democrats filibustered while in the minority as well. Why is it
>>>>>>>>>>>> not their fault?
>>>>>>>>>>>
>>>>>>>>>>> Not in such huge numbers.
>>>>>>>>>>
>>>>>>>>>> Why does the exact number matter?
>>>>>>>>
>>>>>>>> Um, you don't know? The Republicans have been massively obstructing a
>>>>>>>> whole bunch of things. There is a RECORD number of filibusters and
>>>>>>>> cloture votes since Obama got into office.
>>>>>>>
>>>>>>> Are you going to keep posting under different sock-puppets Yorgort?
>>>>>>
>>>>>> Who is Yorgort?
>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> So any talk of what "obama would/could
>>>>>>>>>>>>> do" must be tempered by what the Republican party allows
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Obama has had to backtrack on his promises to his leftist supporters
>>>>>>>>>>>>>> by continuing U.S. efforts in Iraq and Afghanistan, not closing
>>>>>>>>>>>>>> Guantanamo.
>>>>>>>>>>>>>
>>>>>>>>>>>>> IN order to close Gitmo, Obama MUST have cooperation of congress
>>>>>>>>>>>>
>>>>>>>>>>>> Why?
>>>>>>>>>>>
>>>>>>>>>>> Because Obama is not a king?
>>>>>>>>>>
>>>>>>>>>> You're joking right?
>>>>>>>>
>>>>>>>> Not at all. Things like this require legislation. Obama isn't a
>>>>>>>> legislator.
>>>>>>>>
>>>>>>>>> Recess appointment where there is no recess?
>>>>>>>>
>>>>>>>> The senate was on recess. But that is really irrelevant because Obama
>>>>>>>> was not creating legislation; he was filling vacancies.
>>>>>>>>
>>>>>>>
>>>>>>> You're not very bright are you (of course we already knew that).
>>>>>>>
>>>>>>> http://www.foxnews.com/politics/2012/01/16/business-group-leader-says-obamas-recess-appointments-create-const...
>>>>>>
>>>>>> The Senate was in recess. They had not come back on official business yet.
>>>>>
>>>>> Didn't you read the story? They weren't in recess.
>>>>
>>>> They were in recess.
>>>
>>> The story clearly states that they were not in recess. I suggest you
>>> actually read what you've been invited to read twice now.
>>
>> Your citation agrees with me.
>
> Guess reading comprehension is not one of your strong suits...

The "business group leader" (which is simply a conservative charity that
is against unionization) agrees with you. The constitutional experts,
the Justice Department and the United States Constitution, however,
agree with me.

Article 2, Section 2:
The President shall have Power to fill up all Vacancies that may happen
during the Recess of the Senate, by granting Commissions which shall
expire at the End of their next Session.

The Justice Department says that the "convening of periodic pro forma
sessions in which no business is to be conducted does not have the legal
effect of interrupting an intrasession recess otherwise long enough to
qualify as a 'Recess of the Senate' under the Recess Appointments
Clause. In this context, the President therefore has discretion to
conclude that the Senate is unavailable to perform its
advise-and-consent function and to exercise his power to make recess
appointments."

Since the Senate is not available, Obama is unable to get the advice and
consent he needs to fill vacancies....which is the entire point that
portion of Article 2, Section 2.

DanielSan

1/31/2012 11:18:00 AM

0

On 1/31/2012 2:42 AM, NoBody wrote:
> On Mon, 30 Jan 2012 02:49:28 -0800, DanielSan
> <danielsan1977@gmail.com> wrote:
>
>> On 1/30/2012 2:45 AM, NoBody wrote:
>>> On Fri, 27 Jan 2012 07:57:00 -0800, DanielSan
>>> <danielsan1977@gmail.com> wrote:
>>>
>>>> On 1/27/2012 2:24 AM, NoBody wrote:
>>>>> On Thu, 26 Jan 2012 02:58:25 -0800, DanielSan
>>>>> <danielsan1977@gmail.com> wrote:
>>>>>
>>>>>> On 1/26/2012 2:54 AM, DanielSan wrote:
>>>>>>> On 1/26/2012 2:49 AM, NoBody wrote:
>>>>>>>> On Wed, 25 Jan 2012 06:45:58 -0800, DanielSan
>>>>>>>> <danielsan1977@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> On 1/25/2012 3:04 AM, NoBody wrote:
>>>>>>>>>> On Tue, 24 Jan 2012 06:12:10 -0500, NoBody<NoBody@nowhere.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> On Mon, 23 Jan 2012 03:00:35 -0800, DanielSan
>>>>>>>>>>> <danielsan1977@gmail.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> On 1/23/2012 2:57 AM, NoBody wrote:
>>>>>>>>>>>>> On Sun, 22 Jan 2012 21:46:42 -0700, Yoorghis@Jurgis.net wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Sun, 22 Jan 2012 18:19:42 -0800 (PST), Jim Austin
>>>>>>>>>>>>>> <bja@ix.netcom.com> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I was glad that Obama took out bin Laden. However, if Obama's
>>>>>>>>>>>>>>> policies
>>>>>>>>>>>>>>> had been in effect during the Bush administration, bin Laden would
>>>>>>>>>>>>>>> still be at large. Indeed, had word gotten out that Obama
>>>>>>>>>>>>>>> refused to
>>>>>>>>>>>>>>> take out bin Laden when the opportunity arose, his reelection
>>>>>>>>>>>>>>> chances
>>>>>>>>>>>>>>> would have gone down the toilet.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> You forget that any policies under bush were ENTIRELY republican.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Yet you hold Republicans (while in the minority) responsible for the
>>>>>>>>>>>>> Dems spending. Oddly the reverse doesn't seem to apply in your tiny
>>>>>>>>>>>>> mind.
>>>>>>>>>>>>
>>>>>>
>>>>>> <sorry, missed this first part>
>>>>>>
>>>>>>>>>>>> You seem to forget the record number of filibusters and
>>>>>>>>>>>> obstructionism
>>>>>>>>>>>> that Republicans have done since they've been in the minority.
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> And the Dems did the same when they were in the minority -- a
>>>>>>>>>>> distinction without a difference.
>>>>>>>>>
>>>>>>>>> Huge difference. But I don't expect you to realize why or how. You
>>>>>>>>> haven't been told that by your handlers.
>>>>>>>>
>>>>>>>> A distinction without a difference (your fantasies not withstanding).
>>>>>>
>>>>>> Nope. Still a huge difference. You still don't know why, do you?
>>>>>
>>>>> Do tell...
>>>>
>>>> I have already.
>>>
>>> Actually no, you haven't.
>>
>>
>> It's still up there. You haven't snipped it out and it's right there
>> for you to see, read, and understand. I know you did the first one, but
>> did you do the other two?
>
> Your continued evasion is so noted.
>
>>
>>>
>>>>
>>>>>
>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> But, please. Cite Democratic spending policy and how much they
>>>>>>>>>>>> contribute to the current situation.
>>>>>>>>>>>
>>>>>>>>>>> You have looked at the national debt numbers under the Dems and Obama
>>>>>>>>>>> right?
>>>>>>>>>
>>>>>>>>> Yes. And have you looked at what policies make up those debt numbers?
>>>>>>>>
>>>>>>>> Bills signed by Obama and money spent by Obama is his responsiblity
>>>>>>>> and policies.
>>>>>>
>>>>>> So, Obama should've just vetoed the budget bills that came to his desk?
>>>>>
>>>>> Yes. Odd how you would blame the party who wrote the bill for the
>>>>> results, not the guy who okayed them and allowed them to become law.
>>>>
>>>> I see. So, you want the country destroyed.
>>>
>>> Could you try actually addressing the topic this time since your
>>> response has nothing to do with what I sadi?
>>
>> I did. If Obama vetoes spending then the government grinds to a halt
>> and even the military cannot function. Businesses would not be able to
>> function. In short order, the United States becomes a failed state.
>
> Are you saying that the President is not a leader capable of
> negotiatiating a proper spending plan and has no say in the spending
> bills becoming law?

Not with an intransigent Congress with members who say that their sole
purpose is to oust Obama. You think that Congress is blameless here?

>
>>
>> Instead of blaming Obama for things he must do to keep the country
>> operating, how about going after those that refuse to remove these
>> things that balloon the deficit?
>
> Feel free to continue to blame everyone else for spending except for
> the guy who actually signs these bills into law. I guess it's not's
> Bush's fault for his spending as well.

No, it's Bush's fault because Bush wanted the things that the Congress
gave him. Obama wants things but the Congress won't give it to him.

But, feel free to continue to blame Obama for things that Congress does.