Article 7048 of comp.lang.perl: Xref: feenix.metronet.com comp.lang.perl:7048 Path: feenix.metronet.com!news.ecn.bgu.edu!usenet.ins.cwru.edu!howland.reston.ans.net!europa.eng.gtefsd.com!uunet!olivea!pagesat!news.cerf.net!software.com!not-for-mail From: mike@software.com (Michael D'Errico) Newsgroups: comp.lang.perl Subject: Re: Running a Perl net-server under inetd Date: 20 Oct 1993 11:55:38 -0700 Organization: Software Now, Santa Barbara, CA Lines: 25 Distribution: world Message-ID: <2a41ja$kl5@rome.software.com> References: <2a3bpq$o68@horus.mch.sni.de> NNTP-Posting-Host: rome.software.com mike@horus.mch.sni.de (Mike Hoffmann) writes: >I tried this (adapted from the examples in the Camel book): >$othersock = getpeername(0); >($family, $port, $otheraddr) = unpack('S n a4 x8', $othersock); >@otheraddr=unpack('C4', $otheraddr); >printf "$family $port @otheraddr\n"; >How do I get the right socket of the caller? I had thought it would >be mapped to the FD of stdin, i.e. 0. Am I wrong? Use '$othersock = getpeername(STDIN);' >Note that the above wont even work: With the "x8" in the template string, >I get a >"x outside of string at /usr/people/mike/src/internet/sniwp/sniwp line 8." >message. Without the "x8" it runs, but still doesn't return any information. Use 'S n a4 x8' to pack a sockaddr, and 'S n a4' to unpack it. For some reason there is occasionally random junk in the last 8 bytes. Michael D'Errico mike@software.com