Subject: Re: Strange behavious of getpeername(2) on pipe
To: None <tech-kern@netbsd.org>
From: Martin J. Laubach <mjl@emsi.priv.at>
List: tech-kern
Date: 03/27/2001 11:12:13
| last i tried, getpeername() failed on NetBSD in this case. can you try
| a C version to check that it isn't some perl lossage?
The program below (I hope I didn't goof up there) doesn't return
any error either:
laubach1:34 [/tmp] % ./x
getpeername0 returned 0
getpeername1 returned 0
mjl
---- cut here ----
#include <unistd.h>
#include <stdio.h>
#include <sys/socket.h>
main()
{
struct sockaddr sa;
int f[2];
int i, l;
if(pipe(f) != 0)
err(1, "pipe");
l = sizeof(sa);
if((i = getpeername(f[0], &sa, &l)) != 0)
err(1, "getpeername0");
printf("getpeername0 returned %d\n", i);
l = sizeof(sa);
if((i = getpeername(f[1], &sa, &l)) != 0)
err(1, "getpeername1");
printf("getpeername1 returned %d\n", i);
}