Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'socket': 0.07; 'library?': 0.09; 'received:internal': 0.09; 'family,': 0.16; 'fd,': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.44': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:compute4.internal': 0.16; 'received:messagingengine.com': 0.16; 'roy': 0.16; 'type)': 0.16; 'underlying': 0.16; 'wrote:': 0.18; 'thu,': 0.19; '31,': 0.24; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'function': 0.29; 'are.': 0.31; 'ctypes': 0.31; 'them?': 0.31; 'received:66': 0.35; 'skip:s 30': 0.35; 'but': 0.35; 'done': 0.36; 'possible': 0.36; 'subject:?': 0.36; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'from:no real name:2**0': 0.61; 'header:Message-Id:1': 0.63; 'information': 0.63; 'nobody': 0.68; 'smith': 0.68; 'family': 0.73; 'discover': 0.82; '2013,': 0.91; 'to:addr:nobody': 0.96; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:from:to:mime-version:content-transfer-encoding :content-type:in-reply-to:references:subject:date; s=mesmtp; bh= GlO5t4uq+RpfgEskcTE0iaOEOMw=; b=UK9dsUBFiUuwPE0hjNAxES0+U0ltxYjn IkD1Oe2LkrBks1nNQUm13eHoWnO3S1nXatKaN5gz1+ZM7a0TTutntd8+4XDVE3Y0 slW315K6y/gcg+HkcjlYl/ySoIKPOl13d5+029cgvOhs2l7eRxGM2JzvWU1AEDAB 7z9uzNjUdFI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=smtpout; bh=GlO5t4uq+RpfgEskcTE0iaOEOMw=; b=C67 VQuHpaa/ZMUL6S/rZ1KTv6HSVSvTHYzJ+SrdTDgaKuIHE+zN52lx/RcWmRyAromM HsFnJAw4iRpsQ694aaFaDpVv/LaxQhIQ2XLTDNjgstX1On2pf3c6OlgfS4wOfm+t IjO/gTQb4hykRP3Jp1i93vHFtZUud0xo7IWoT2rg= X-Sasl-Enc: HlosNs9oSVltFk18niu7Cufq9hjXa0vj0auHTBbh/gb8 1383332138 From: random832@fastmail.us To: Nobody , python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-d4893488 In-Reply-To: References: Subject: Re: getpeername() on stdin? Date: Fri, 01 Nov 2013 14:55:38 -0400 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1383332149 news.xs4all.nl 15923 [2001:888:2000:d::a6]:37389 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:58285 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?