On 11-11-01 12:26 PM, A Mennucc wrote:
[snip]
> I can also tell that the freevo-box is running Debian/squeeze/i386 ,
> and uses Python 2.6.6

Unfortunately there's really nothing in here that tells me what's going
wrong.  Nothing looks out of the ordinary.

kaa.Socket uses AF_INET6 sockets exclusively, and uses IPv4-mapped IPv6
addresses for IPv4 addresses on AF_INET6 sockets.  This is why you see:

$ netstat --inet6 -an | grep 19999
tcp6       0      0 127.0.0.1:19999         :::*                    LISTEN 

That's expected; netstat is just showing the IPv4-mapped address
(::ffff:127.0.0.1) stripped of the prefix.  These sockets can be
connected over IPv4.

Getting a /network/ unreachable when you try to connect to 127.0.0.1 is
perplexing.  My first instinct was that lo was down, but your ip addr ls
output says otherwise.

Doing a bit of Googling, I see that the BSDs don't support IPv4-mapped
addresses on IPv6 sockets.  This might be a reason to change kaa.Socket
to use AF_INET or AF_INET6 sockets selectively.  Are you using a BSD
kernel on Debian?  That could explain it, but I wouldn't have expected
the ip(8) calls to work in that case, or at least be so exactly
formatted.  OTOH I don't know BSD at all. :)

Assuming you're not using BSD, I'd still like to understand what's
happening here.  Can you please try the attached crudely constructed
test script and dump the output?  Make sure ::1 isn't in the localhost
address list in /etc/hosts.

Thanks!
import socket

def to_v6(addr):
    return '::ffff:' + addr if ':' not in addr and addr else addr


def v6sock(addr, port, bind=True, get=False):
    print 'AF_INET6 %s to %s:%d' % ('bind' if bind else 'connect', addr, port)
    addrs = socket.getaddrinfo(addr, port, socket.AF_INET6, socket.SOCK_STREAM, 0, socket.AI_V4MAPPED | socket.AI_ALL)
    for addrinfo in (a[4] for a in addrs):
        newinfo = (to_v6(addrinfo[0]),) + addrinfo[1:]
        print '  try %s -> %s' % (addrinfo, newinfo)
        try:
            sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
            sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            if bind:
                sock.bind(newinfo)
            else:
                sock.connect(newinfo)
            if get:
                return sock
        except socket.error, e:
            print '    -> failed:', e


def v4sock(addr, port, bind=True, get=False):
    print 'AF_INET %s to %s:%d' % ('bind' if bind else 'connect', addr, port)
    addrs = socket.getaddrinfo(addr, port, socket.AF_INET, socket.SOCK_STREAM, 0, socket.AI_ALL)
    for addrinfo in (a[4] for a in addrs):
        print '  try %s' % repr(addrinfo)
        try:
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            if bind:
                sock.bind(addrinfo)
            else:
                sock.connect(addrinfo)
            if get:
                return sock
        except socket.error, e:
            print '    -> failed:', e


for host in ('localhost', '127.0.0.1'):
    print '------', host
    v4sock(host, 20011)
    lsock = v4sock(host, 20011, get=True)
    if lsock:
        lsock.listen(10)
        v4sock(host, 20011, False)
        lsock.close()
    else:
        print '  skipping connect'

for host in ('localhost', 'ip6-localhost', '127.0.0.1', '::1'):
    print '------', host
    v6sock(host, 20011)
    lsock = v6sock(host, 20011, get=True)
    if lsock:
        lsock.listen(10)
        v6sock(host, 20011, False)
        lsock.close()
    else:
        print '  skipping connect'
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Freevo-devel mailing list
Freevo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to