Support IPv6 connections
This commit is contained in:
parent
7a177a6360
commit
5fdc1eff65
@ -21,6 +21,7 @@ import sys
|
||||
import threading
|
||||
import time
|
||||
import traceback
|
||||
import os
|
||||
|
||||
from oyoyo.parse import parse_raw_irc_command
|
||||
|
||||
@ -99,7 +100,7 @@ class IRCClient(object):
|
||||
To enable blocking pass blocking=True.
|
||||
"""
|
||||
|
||||
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.socket = None
|
||||
self.nickname = ""
|
||||
self.hostmask = ""
|
||||
self.ident = ""
|
||||
@ -177,13 +178,14 @@ class IRCClient(object):
|
||||
retries = 0
|
||||
while True:
|
||||
try:
|
||||
self.socket.connect(("{0}".format(self.host), self.port))
|
||||
self.socket = socket.create_connection(("{0}".format(self.host), self.port))
|
||||
break
|
||||
except socket.error as e:
|
||||
retries += 1
|
||||
self.stream_handler('Error: {0}'.format(e), level="warning")
|
||||
if retries > 3:
|
||||
break
|
||||
exit(os.EX_UNAVAILABLE)
|
||||
|
||||
if not self.blocking:
|
||||
self.socket.setblocking(0)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user