1 #服务端
2 from socket
import *
3 import json
4 def recvMsg(s):
5 while True:
6 #接收用户的信息
7 data,address = s.recvfrom(1024
)
8 data =
json.loads(data)
9 print(data,address)
10
11 if data[
'type'] ==
'enter':
12 # 将用户进入聊天室的信息发给其它所有在线用户
13 sendToAll((
'>>系统:%s进入了聊天室'
转载请注明原文地址: https://mac.8miu.com/read-23114.html