1.1 --- a/gmyth-stream/plugins/comm/tcp.py Tue Mar 27 23:57:42 2007 +0100
1.2 +++ b/gmyth-stream/plugins/comm/tcp.py Fri Mar 30 04:12:52 2007 +0100
1.3 @@ -1,3 +1,4 @@
1.4 +import lib
1.5 import time
1.6 import socket
1.7
1.8 @@ -12,17 +13,20 @@
1.9 self.tcp.bind( (self.host, self.port) )
1.10 self.tcp.listen(1)
1.11
1.12 - def now(self):
1.13 - return time.strftime("%Y-%m-%d %H:%M:%S");
1.14 + def getMsg(self, size):
1.15 + return self.con.recv(size)
1.16
1.17 - def getMsg(self, size):
1.18 - con = self.data[0]
1.19 - return con.recv(size)
1.20 + def sendMsg(self, msg):
1.21 + self.con.send(msg)
1.22 +
1.23 + def Ack(self, command):
1.24 + msg = "[%s] Command %s received" % (lib.now(), command)
1.25 + self.sendMsg(msg + "\n")
1.26
1.27 def getRequest(self):
1.28 - self.data = self.tcp.accept()
1.29 - print "[%s] Received request from ip=%s" % (self.now(), self.data[1] )
1.30 - return self.data
1.31 + self.con, self.client = self.tcp.accept()
1.32 + print "[%s] Received request from ip=%s" % (lib.now(), self.client )
1.33 + return (self.con, self.client)
1.34
1.35 def disconnect_client(self, connection):
1.36 connection.close()