getpeername() on stdin?
random832 at fastmail.us
random832 at fastmail.us
Fri Nov 1 14:55:38 EDT 2013
On Thu, Oct 31, 2013, at 21:12, Nobody wrote:
> On Thu, 31 Oct 2013 12:16:23 -0400, Roy Smith wrote:
>
> > I want to do getpeername() on stdin. I know I can do this by wrapping a
> > socket object around stdin, with
> >
> > s = socket.fromfd(sys.stdin.fileno(), family, type)
> >
> > but that requires that I know what the family and type are. What I want
> > to do is discover the family and type by looking at what getpeername()
> > and/or getsockname() return. Can this be done with the standard library?
>
> I think that you'd need to use ctypes to access the underlying
> getpeername() function from libc.
If it's possible to get this information with only the fd, then why does
socket.fromfd require them?
More information about the Python-list
mailing list