IPv6 question

John Burton john.burton at jbmail.com
Sun Feb 15 06:41:44 EST 2004


"John Burton" <john.burton at jbmail.com> wrote in message
news:9r14g1-1vu.ln1 at neon.jbmail.com...
> I'm not sure if this is a question about python socket support or sockets
in
> general ...
>
> I have a socket server with which I want to accept incoming connections on
> ipv4 and ipv6.
> I've found that if I create the listening socket with
> sock = socket(AF_INET, SOCK_STREAM)
> it will accept connections on ipv4 (only) and if I create it with
> sock = socket(AF_INET6, SOCK_STREAM)
> it will accept connections with ipv6 (only)
>
> Is there a way to make a single socket accept connections using both
> protocols?
> Or do I need create two sockets and listen on them both?

Oops I missed out the point of my question ...

If I need to create an IPv4 socket and IPv6 socket and listen on both that
doesn't
seem to work.

 sock4 = socket(AF_INET, SOCK_STREAM)
 sock4.bind(('', 12345))
 sock6 = socket(AF_INET6, SOCK_STREAM)
 sock6.bind(('', 12345))

I get an error that the address is already in use on the 2nd bind even
though it's to a different
socket type. This is on linux.
Has anyone got this to work? Or am I missing something?





More information about the Python-list mailing list