From f631eda05ca45b7b503bb26aca746d735165d308 Mon Sep 17 00:00:00 2001 From: Jeix Date: Sun, 5 Feb 2012 15:53:40 +0100 Subject: xdcc fix --- module/network/XDCCRequest.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'module/network/XDCCRequest.py') diff --git a/module/network/XDCCRequest.py b/module/network/XDCCRequest.py index 92ccb4839..f03798c17 100644 --- a/module/network/XDCCRequest.py +++ b/module/network/XDCCRequest.py @@ -63,8 +63,9 @@ class XDCCRequest(): return socket.socket() - def download(self, ip, port, filename, progressNotify=None): + def download(self, ip, port, filename, irc, progressNotify=None): + ircbuffer = "" lastUpdate = time() cumRecvLen = 0 @@ -94,6 +95,8 @@ class XDCCRequest(): remove(filename) raise Abort() + self._keepAlive(irc, ircbuffer) + data = dccsock.recv(4096) dataLen = len(data) self.recv += dataLen @@ -124,7 +127,21 @@ class XDCCRequest(): return filename - + def _keepAlive(self, sock, readbuffer): + fdset = select([sock], [], [], 0) + if sock not in fdset[0]: + return + + readbuffer += sock.recv(1024) + temp = readbuffer.split("\n") + readbuffer = temp.pop() + + for line in temp: + line = line.rstrip() + first = line.split() + if first[0] == "PING": + sock.send("PONG %s\r\n" % first[1]) + def abortDownloads(self): self.abort = True -- cgit v1.2.3