Added ipv4/ipv6 check

master
Ruakij 3 years ago
parent a083a7eeae
commit 2029d53e2a

@ -23,7 +23,13 @@ def main(args):
startListen(s) startListen(s)
def setupSocket(address, port): def setupSocket(address, port):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # IPv4/IPv6-check
if address == "" or ":" in address:
family = socket.AF_INET6
else:
family = socket.AF_INET
s = socket.socket(family, socket.SOCK_DGRAM)
s.bind((address, port)) s.bind((address, port))
return s return s

Loading…
Cancel
Save