author | renatofilho |
Wed Mar 28 21:26:42 2007 +0100 (2007-03-28) | |
branch | trunk |
changeset 468 | f4c6061f6f39 |
parent 453 | a806d8ad0ff0 |
child 470 | 57833200a415 |
permissions | -rw-r--r-- |
1 import time
2 import socket
4 class Server:
6 def __init__(self, config):
7 self.host = ''
8 self.port = int(config.get("Comm", "port"))
9 self.finish = 0
11 self.tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
12 self.tcp.bind( (self.host, self.port) )
13 self.tcp.listen(1)
15 def now(self):
16 return time.strftime("%Y-%m-%d %H:%M:%S");
18 def getMsg(self, size):
19 con = self.data[0]
20 return con.recv(size)
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
27 def disconnect_client(self, connection):
28 connection.close()
30 def stop(self):
31 self.tcp.close()