Skip to content

socket.getfqdn() doesn't on Windows #37230

Closed

Description

@olson
mannequin
BPO 615472
Nosy @tim-one, @loewis

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2002-09-30.16:02:53.000>
created_at = <Date 2002-09-27.12:32:47.000>
labels = ['library']
title = "socket.getfqdn() doesn't on Windows"
updated_at = <Date 2002-09-30.16:02:53.000>
user = 'https://bugs.python.org/olson'

bugs.python.org fields:

activity = <Date 2002-09-30.16:02:53.000>
actor = 'tim.peters'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2002-09-27.12:32:47.000>
creator = 'olson'
dependencies = []
files = []
hgrepos = []
issue_num = 615472
keywords = []
message_count = 8.0
messages = ['12512', '12513', '12514', '12515', '12516', '12517', '12518', '12519']
nosy_count = 3.0
nosy_names = ['tim.peters', 'loewis', 'olson']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue615472'
versions = []

Activity

  1. olson commented on Sep 27, 2002

    olsonmannequin
    MannequinAuthor

    On windows, socket.getfqdn() doesn't return a fully qualified
    name. Further, it returns the NETBIOS name (I think they call it
    that) of the computer, not a name that's useful for
    networking:

    C:\>\Python22\python.exe
    Python 
    2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on 
    win32
    Type "help", "copyright", "credits" or "license" for more 
    information.
    >>> import socket
    >>> 
    socket.getfqdn()
    'lorax'

    Python 2.2.1 (from
    python.org), Windows 2000.

    --bob

  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Sep 27, 2002
  3. loewis commented on Sep 29, 2002

    loewismannequin
    Mannequin

    Logged In: YES
    user_id=21627

    This is not true; getfqdn returns a fully qualified name
    even on Windows. If it doesn't do that on your system, this
    reason is different than just being Windows.

    Can you please report the outcome of the following calls?

    socket.gethostname()
    name = _
    gethostbyaddr(name)
  4. olson commented on Sep 29, 2002

    olsonmannequin
    MannequinAuthor

    Logged In: YES
    user_id=20112

    Is this what you're looking for?

    $ python
    Python 2.1.1 (#2, Aug 
    23 2001, 10:41:44) 
    [GCC 2.95.3-5 (cygwin special)] on 
    cygwin
    Type "copyright", "credits" or "license" for more 
    information.
    >>> import socket
    >>> 
    socket.getfqdn()
    'only'
    >>> 
    socket.gethostname()
    'only'
    >>> 
    socket.gethostbyaddr(socket.gethostname())
    ('only', [], 
    ['140.221.10.174', '192.168.153.1', '192.168.43.1'])

    (different
    machine & python, same behavior; the one I used before is now on a
    network where it doesn't have a real name).

    I've seen this on all the
    Windows machines I've used; it seems like Windows refuses to let the
    DNS-based name come through, if it already thinks it knows the name
    based on the Netbios name of the machine.

  5. loewis commented on Sep 30, 2002

    loewismannequin
    Mannequin

    Logged In: YES
    user_id=21627

    It works fine for me, on an XP system. What Windows version?

    In "computer properties/computer name/Change", what do you
    see as "complete computer name"? In "more", what is the
    "primary domain suffix"? (I only have a German installation,
    so I'm uncertain how this reads in an English installation)
    I still suspect your machine is misconfigured.

  6. olson commented on Sep 30, 2002

    olsonmannequin
    MannequinAuthor

    Logged In: YES
    user_id=20112

    This is win2k. The "full computer name" doesn't have the full domain; and
    there isn't a primary domain suffix, so that may be what you mean by
    misconfigured.

    However, when I get IP and DNS information via
    DHCP, I would not expect to have to manually configure the computer
    name each time I use the machine in a differnet place (this is what DHCP
    is for). A DNS lookup on my IP address should give me the full information.
    Sigh, I suspect I may be up against a windows limitation perhaps.

  7. olson commented on Sep 30, 2002

    olsonmannequin
    MannequinAuthor

    Logged In: YES
    user_id=20112

    This is the other thing that bugs me about this problem:

    $ 
    python
    Python 2.1.1 (#2, Aug 23 2001, 10:41:44) 
    [GCC 2.95.3-5 
    (cygwin special)] on cygwin
    Type "copyright", "credits" or "license" 
    for more information.
    >>> import socket
    >>> 
    socket.gethostbyaddr(socket.gethostbyname("only"))
    ('only', [], 
    ['140.221.10.174', '192.168.153.1', '192.168.43.1'])
    >>> 
    socket.gethostbyaddr(socket.gethostbyname("moonbeam"))
    ('moonbeam.mcs.anl.gov', 
    [], ['140.221.9.223'])

    It doesn't make sense that the first doesn't
    return the full name, while the second does.

    --bob

  8. loewis commented on Sep 30, 2002

    loewismannequin
    Mannequin

    Logged In: YES
    user_id=21627

    If you get your configuration via dhcp, the DHCP server
    should provide you with your domain name as well. If it
    doesn't, the DHCP server is misconfigured; ask your
    administrator. Do you have any indication that any other
    program on your system is capable of computing the domain
    suffix you want to see?

    The issue with properly resolving a remote system (assuming
    'moonbeam' is remote) is a well-known (to me, atleast)
    limitation of the Windows Socket library (winsock): if you
    are requesting information on the local system, DNS is not
    considered. DNS queries are only sent for remote systems.

    I'll close this bug as third-party (MS, in this case); if
    you later find that there is indeed a Python bug, please
    make a new report.

  9. tim-one commented on Sep 30, 2002

    @tim-one
    Member

    Logged In: YES
    user_id=31435

    Changed group to "3rd Party", as Martin suggested.

  10. transferred this issue fromon Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directory

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions