[Python-ideas] PEP 3156: getting the socket or peer name from the transport

Yuval Greenfield ubershmekel at gmail.com
Thu Jan 24 19:45:17 CET 2013


On Thu, Jan 24, 2013 at 8:23 PM, Guido van Rossum <guido at python.org> wrote:

> A pragmatic question popped up: sometimes the protocol would like to
> know the name of the socket or its peer, i.e. call getsockname() or
> getpeername() on the underlying socket. (I can imagine wanting to log
> this, or do some kind of IP address blocking.)
>
> What should the interface for this look like? I can think of several ways:
>
> A) An API to return the underlying socket, if there is one. (In the
> case of a stack of transports and protocols there may not be one, so
> it may return None.) Downside is that it requires the transport to use
> sockets -- if it were to use some native Windows API there might not
> be a socket object even though there might be an IP connection with
> easily-accessible address and peer.
>

I feel (A) is the best option as it's the most flexible - underlying
transports can have many different special methods. No?

Yuval Greenfield
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130124/e19cef43/attachment.html>


More information about the Python-ideas mailing list