Date: Sun, 1 Sep 1996 15:01:01 -0400 (EDT) From: Matt Braithwaite <m-braithwaite@sjca.edu> To: freebsd-questions@freebsd.org Subject: getpeername() returns 0 when called for non-socket! Message-ID: <199609011901.PAA00302@continuity.sjca.edu>
next in thread | raw e-mail | index | archive | help
greetings, i found the following problem (or what i think is a problem) under 2.1.5-RELEASE. in the PH (CCSO phonebook) server, qi, there is a function that tries to detect what its standard input is. it calls getpeername() to see whether its stdin is a network connection, which it would be when invoked by inetd. the trouble is that this test is succeeding when it shouldn't be. i have a program that uses perl's open2 function. open2 does a fork and exec such that qi's stdin is a pipe which my perl program writes to, and such that qi's stdout/stderr is a pipe which my perl program reads from. so essentially i have a perl script to send commands to qi and read the results using pipes. however, when qi calls getpeername() on its standard input in this context, getpeername() returns 0! qi then reads the IP address returned, which is total garbage, but it proceeds thinking that its standard input is NOT a pipe. for reasons not worth going into, this breaks some stuff i depend on. can anyone explain this behavior? -- Matt Braithwaite #!/bin/perl -s-- -export-a-crypto-system-sig -RSA-3-lines-PERL http:// $m=unpack(H.$w,$m."\0"x$w),$_=`echo "16do$w 2+4Oi0$d*-^1[d2%Sa www.sjca.edu/ 2/d0<X+d*La1=z\U$n%0]SX$k"[$m*]\EszlXx++p|dc`,s/^.|\W//g,print ph/m-braithwaite pack('H*',$_)while read(STDIN,$m,($w=2*$d-1+length$n&~1)/2)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199609011901.PAA00302>