use socket.create_connection() for dualstack and socket timeout

This commit is contained in:
jkhsjdhjs 2024-01-30 23:41:32 +00:00
parent e3cdce4f12
commit f92d59dd91

11
bert.py
View File

@ -38,10 +38,8 @@ y = "\x038"
r = "\x034"
g = "\x033"
context = ssl.create_default_context()
with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as sock:
irc = context.wrap_socket(sock, server_hostname=host)
# global variable for the socket, see connect()
irc = None
# Currency API
def get_exchange():
@ -71,8 +69,11 @@ def safeexit():
def connect(host, port):
global irc
print("Connecting to "+host+":"+str(port))
irc.connect((host, port))
context = ssl.create_default_context()
with socket.create_connection((host, port)) as sock:
irc = context.wrap_socket(sock, server_hostname=host)
def sendRaw(data):