Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Feb 2001 06:32:14 -0500 (EST)
From:      bill <billt@what.ifelse.org>
To:        <freebsd-questions@freebsd.org>
Subject:   getsockname + getnameinfo = garbage
Message-ID:  <Pine.BSF.4.31.0102060603370.29920-100000@zaius.poa>

next in thread | raw e-mail | index | archive | help
Hello,

I'm using xawtv-3.30 on freebsd and it uses this function to get the name
of the server and the client:

    /* me */
    length =3D sizeof(ss);
    if (-1 =3D=3D getsockname(fd,(struct sockaddr*)&ss,&length)) {
        perror("getsockname");
        return;
    }
    if (debug)
        fprintf(stderr,"*");

    getnameinfo((struct sockaddr*)&ss,length,
                me,INET6_ADDRSTRLEN,port,16,
                NI_NUMERICHOST | NI_NUMERICSERV);
    if (debug)
        fprintf(stderr,"*");

for variables 'me' and 'peer'. it then compares 'me' and 'peer' to check
if the X server is local. This check always fails because it seems that
these functions return this garbage:

This is xawtv-3.30, running on FreeBSD/i386 (4.2-STABLE)
[...]
check if the X-Server is local ... **** ok
x11 socket: me=3D8=90=04=08(S=08=01, server=3D=9A`=07(=9F=A1=04=08=A8=C3,(

I get xawtv to work by ensuring that the results of this check don't
matter. In the man page for getsockname(2), the BUGS section mentions:

     Names bound to sockets in the UNIX domain are inaccessible;
     getsockname returns a zero length name.

Being a C beginner, I am curious if this is what could be causing the
garbage, and if so is there a  way to work around it? I have seen
this happen on another, completely different freebsd box, but it doesn't
happen on Linux.

Thanks for any info,
Bill



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.31.0102060603370.29920-100000>