Search code examples
pythonsocketsipv6

ipv6 socket_programming python


i am trying to run this simple code to make client - server connection this is server_side :

   from socket import *
   s = socket(AF_INET6 , SOCK_STREAM  , 0)
   s.bind(("127.0.0.1" , 1234  , 0 , 0))

but i got error

what should i do ? thanks.


Solution

  • 127.0.0.1 is an IPv4 address. It is not valid for AF_INET6.

    Try

    s.bind(("::1" , 1234))