| 123456789101112131415161718192021222324252627 |
- import threading
- import time
- class RECVSERVER(threading.Thread):
- def __init__(self, sock, config):
- threading.Thread.__init__(self)
- self.setDaemon(True)
- self.sock = sock
- def __del__(self):
- self.sock.close()
- pass
- def run(self):
- # 接收
- while True:
- try:
- msg = self.sock.recv(1024)
- if not msg:
- print('无数据')
- continue
- else:
- print('接收数据', msg.decode('utf-8'), time.ctime())
- except:
- print('服务器断开')
- break
|