gmyth-stream/plugins/comm/tcp.py
author renatofilho
Wed Mar 28 21:26:42 2007 +0100 (2007-03-28)
branchtrunk
changeset 468 f4c6061f6f39
parent 453 a806d8ad0ff0
child 470 57833200a415
permissions -rw-r--r--
[svn r473] memory leek fix
     1 import time
     2 import socket
     3 
     4 class Server:
     5 
     6     def __init__(self, config):
     7         self.host = ''
     8         self.port = int(config.get("Comm", "port"))
     9         self.finish = 0
    10 
    11         self.tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    12         self.tcp.bind( (self.host, self.port) )
    13         self.tcp.listen(1)
    14 
    15     def now(self):
    16         return time.strftime("%Y-%m-%d %H:%M:%S");
    17 
    18     def getMsg(self, size):
    19         con = self.data[0]
    20         return con.recv(size)
    21 
    22     def getRequest(self):
    23         self.data = self.tcp.accept()
    24         print "[%s] Received request from ip=%s" % (self.now(), self.data[1] )
    25         return self.data
    26 
    27     def disconnect_client(self, connection):
    28         connection.close()
    29 
    30     def stop(self):
    31         self.tcp.close()