use socket.create_connection() for dualstack and socket timeout
				
					
				
			This commit is contained in:
		
							
								
								
									
										11
									
								
								bert.py
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								bert.py
									
									
									
									
									
								
							| @@ -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): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user