socket.gethostbyaddr problem

Discussion in 'Python' started by Mohammed Smadi, Sep 18, 2005.

  1. hi;
    I am trying to do some very basic socket programming and i get the
    following error. Any help will be appreciated:

    Code:
    import socket
    x = socket.gethostbyaddr("www.google.ca")

    return an error: socket.herror: (1, 'Unknown host')

    I tried replacing the web URL with an IP address on the net, on my LAN and
    it does not work. It only works with "localhost" which is not very
    useful. Am using Python 2.3.4 if that matters.

    any direction will be great

    moe smadi
    Mohammed Smadi, Sep 18, 2005
    #1
    1. Advertising

  2. Mohammed Smadi wrote:
    > hi;
    > I am trying to do some very basic socket programming and i get the
    > following error. Any help will be appreciated:
    >
    > Code:
    > import socket
    > x = socket.gethostbyaddr("www.google.ca")
    >
    > return an error: socket.herror: (1, 'Unknown host')


    You're using the wrong method.

    >>> socket.gethostbyname("www.google.ca")

    '66.102.9.147'


    --Irmen
    Irmen de Jong, Sep 18, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Neil Aggarwal

    gethostbyaddr returning null for CNAME records

    Neil Aggarwal, Feb 25, 2004, in forum: C Programming
    Replies:
    2
    Views:
    3,831
    Ben Pfaff
    Feb 25, 2004
  2. Harlin Seritt

    socket.gethostbyaddr() question

    Harlin Seritt, Jan 15, 2006, in forum: Python
    Replies:
    2
    Views:
    2,076
    Steve Holden
    Jan 15, 2006
  3. gethostbyaddr/nslookup failed

    , Jul 27, 2005, in forum: C Programming
    Replies:
    1
    Views:
    548
    Artie Gold
    Jul 27, 2005
  4. shailesh
    Replies:
    1
    Views:
    447
    Sion Arrowsmith
    Jan 28, 2008
  5. cjblaine
    Replies:
    1
    Views:
    323
    Ned Deily
    Apr 28, 2011
Loading...

Share This Page