Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!zen.net.uk!dedekind.zen.co.uk!reader02.nrc01.news.zen.net.uk.POSTED!not-for-mail From: Nobody Subject: Re: getpeername() on stdin? Date: Fri, 01 Nov 2013 01:12:31 +0000 User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-Id: Newsgroups: comp.lang.python References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lines: 14 Organization: Zen Internet NNTP-Posting-Host: fd198141.news.zen.co.uk X-Trace: DXC=l3jR`02bAbYXHnR5[[clC[]G;bfYi23hT=dR0\ckLKGPWeZ<[7LZNRV5:9_Qi7c;5\M2Z^cWRFGA[_6DK?DJ4eBZ X-Complaints-To: abuse@zen.co.uk Xref: csiph.com comp.lang.python:58222 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.