Skip to content

socket.socket.getsockname() has inconsistent UNIX/Windows behavior #45390

Closed

Description

@janssen
mannequin
BPO 1049
Nosy @loewis, @tpn

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 2007-08-29.16:48:05.367>
created_at = <Date 2007-08-28.23:46:32.297>
labels = ['type-bug', 'library']
title = 'socket.socket.getsockname() has inconsistent UNIX/Windows behavior'
updated_at = <Date 2008-04-10.12:40:08.754>
user = 'https://bugs.python.org/janssen'

bugs.python.org fields:

activity = <Date 2008-04-10.12:40:08.754>
actor = 'trent'
assignee = 'none'
closed = True
closed_date = <Date 2007-08-29.16:48:05.367>
closer = 'loewis'
components = ['Library (Lib)']
creation = <Date 2007-08-28.23:46:32.297>
creator = 'janssen'
dependencies = []
files = []
hgrepos = []
issue_num = 1049
keywords = []
message_count = 3.0
messages = ['55390', '55425', '65280']
nosy_count = 3.0
nosy_names = ['loewis', 'janssen', 'trent']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue1049'
versions = ['Python 2.6', 'Python 3.0']

Activity

  1. janssen commented on Aug 28, 2007

    janssenmannequin
    MannequinAuthor

    The behavior and return value for calling socket.socket.getsockname() on
    an unconnected unbound socket is unspecified. On UNIX, it returns an
    address ('0.0.0.0', 0), while on Windows it raises an obscure exception
    "error: (10022, 'Invalid argument')". This should be regularized; I'd
    suggest returning None if there is no name (address) for the socket.

  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    type-bugAn unexpected behavior, bug, or error
    on Aug 28, 2007
  3. loewis commented on Aug 29, 2007

    loewismannequin
    Mannequin

    I think it is neither possible nor "good" to produce a uniform result.
    Python traditionally exposes APIs "as-is", providing the system actually
    has an API with the same name. It never tries to hide differing system
    behaviors in the Python wrapper; if systems vary and it is desirable to
    provide a uniform API, a different API is added.

    However, it is also not possible to make that uniform, as getsockname(3)
    gives an unspecified result, so it is not possible for Python to
    actually determine whether there was a meaningful result.

    Closing as rejected.

  4. janssen commented on Apr 9, 2008

    janssenmannequin
    MannequinAuthor

    Here's what the OS X man page says:

    The getsockname() function returns the value 0 if successful; otherwise
    the value -1 is returned and the global variable errno is set to
    indicate the error.

  5. transferred this issue fromon Apr 10, 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/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions