homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: socket.socket.getsockname() has inconsistent UNIX/Windows behavior
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.0, Python 2.6
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: janssen, loewis, trent
Priority: normal Keywords:

Created on 2007年08月28日 23:46 by janssen, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Messages (3)
msg55390 - (view) Author: Bill Janssen (janssen) * (Python committer) Date: 2007年08月28日 23:46
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.
msg55425 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007年08月29日 16:48
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.
msg65280 - (view) Author: Bill Janssen (janssen) * (Python committer) Date: 2008年04月09日 23:28
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.
History
Date User Action Args
2022年04月11日 14:56:26adminsetgithub: 45390
2008年04月10日 12:40:08trentsetnosy: + trent
2008年04月09日 23:28:18janssensetmessages: + msg65280
2007年08月29日 16:48:05loewissetstatus: open -> closed
resolution: rejected
messages: + msg55425
nosy: + loewis
2007年08月28日 23:46:32janssencreate

AltStyle によって変換されたページ (->オリジナル) /