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