I want to connect my program with ipv6 and not ipv4 My code is:
import socket
import threading
HEADER = 128
PORT = someport
#SERVER = socket.gethostbyname(socket.gethostname())
SERVER = 'someip'
ADDR = (SERVER, PORT)
FORMAT = "utf-8"
DISCONNECTED_MESSAGE = "!DISCONNECTED"
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(ADDR)
I already know how to do it with ipv4, but not with ipv6.
CodePudding user response:
There is actually a very simple solution to that You could add:
server = socket.socket(socket.AF_INET**6**, socket.SOCK_STREAM)
and then put the ipv6 on your server variable