IPv6 address not connecting but IPv4-mapped -IPv6 does. Please help.

Discussion in 'Network Routers' started by DanielJohnson, Jan 7, 2009.

  1. hi, I am a newbie unix programmer and playing around with some IPv4
    and IPv6 code. I have a Ubuntu box and its ifconfig is as follows:

    eth0 Link encap:Ethernet HWaddr 00:1a:a0:b5:77:78
    inet addr:10.54.190.137 Bcast:10.54.255.255 Mask:
    255.255.0.0
    inet6 addr: fe80::21a:a0ff:feb5:7778/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:301145950 errors:0 dropped:0 overruns:0 frame:0
    TX packets:117146034 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:134173737050 (124.9 GB) TX bytes:95018619543 (88.4
    GB)
    Interrupt:16

    lo Link encap:Local Loopback
    inet addr:127.0.0.1 Mask:255.0.0.0
    inet6 addr: ::1/128 Scope:Host
    UP LOOPBACK RUNNING MTU:16436 Metric:1
    RX packets:30803018 errors:0 dropped:0 overruns:0 frame:0
    TX packets:30803018 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:1652234089 (1.5 GB) TX bytes:1652234089 (1.5 GB)

    I have a very simple client and server python program. Server listens
    on socket, the client connects to the server. In this program if
    server gives IPv4 address, the server and client both talk fine. If
    client gives a IPv4-mapped-IPv6 address like "::ffff:10.54.190.37",
    the server and client both talk fine. But if I give address as
    "fe80::21a:a0ff:feb5:7778", I get an errno = 22 (invalid argument). If
    you see above, the interface eth0 has IPv4 address (10.54.190.137) and
    IPv6 address (fe80::21a:a0ff:feb5:7778).

    can you please suggest where am I going wrong ? Can't I connect using
    IPv6 address only.

    Please shed some insight.

    thanks. Every reply is greatly appreciated.

    The programs are as follows:

    # client.py
    # Echo client program
    import socket
    import sys

    HOST = 'fe80::21a:a0ff:feb5:7778' # The remote host
    #HOST = '::ffff:10.54.190.137' # The remote host
    #HOST = '::1'
    PORT = 50007 # The same port as used by the server
    s = None
    for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC,
    socket.SOCK_STREAM):
    af, socktype, proto, canonname, sa = res
    try:
    s = socket.socket(af, socktype, proto)
    except socket.error, msg:
    s = None
    continue
    try:
    s.connect(sa)
    except socket.error, msg:
    s.close()
    s = None
    continue
    break
    if s is None:
    print 'could not open socket'
    sys.exit(1)
    s.send('Hello, world')
    data = s.recv(1024)
    s.close()
    print 'Received', repr(data)

    #server.py
    # Echo server program
    import socket
    import sys

    HOST = None # Symbolic name meaning all available
    interfaces
    PORT = 50007 # Arbitrary non-privileged port
    s = None
    for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC,
    socket.SOCK_STREAM, 0,
    socket.AI_PASSIVE):
    af, socktype, proto, canonname, sa = res
    try:
    s = socket.socket(af, socktype, proto)
    except socket.error, msg:
    s = None
    continue
    try:
    s.bind(sa)
    s.listen(1)
    except socket.error, msg:
    s.close()
    s = None
    continue
    break
    if s is None:
    print 'could not open socket'
    sys.exit(1)
    conn, addr = s.accept()
    print 'Connected by', addr
    while 1:
    data = conn.recv(1024)
    if not data: break
    conn.send(data)
    conn.close()
     
    DanielJohnson, Jan 7, 2009
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.