Python课程-w73班
Louyj's Blog
Toggle navigation
Python课程-w73班
Home
班级课件
课堂代码
课后作业
学习资料
Archives
Tags
2022-05-22课堂代码
2022-05-22 08:18:21
10
0
0
python-w73
udp_server.py ``` import socket # 1. 初始化socket s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # SOCK_DGRAM指定UDP协议 # 2. 绑定地址(ip+端口) host = '127.0.0.1' port = 50000 s.bind((host, port)) # 3. 收发数据 message, address = s.recvfrom(1024) print("收到客户端消息: " + message.decode('utf-8')) s.sendto(b'hello', address) # 4. 结束交互 s.close() ''' cpu / 内存 / 磁盘 文件10G->内存(8G) 2行-->操作系统认为后2行->操作把后2行读到cache LRU cache满了, 会把最近没有使用的缓存给清掉 1. 内存-> 磁盘缓存 2. cpu-->寄存器-->高速缓存 -> 内存 3. redis缓存系统, memcache 缓存 android --> linux ''' ``` udp_client.py ``` import socket # 1. 初始化socket s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # SOCK_DGRAM指定UDP协议 # 2. 收发数据 host = '127.0.0.1' port = 50000 s.sendto(b'hello', (host, port)) message, address = s.recvfrom(1024) print("收到服务器的消息: " + message.decode('utf-8')) # 3. 结束交互 s.close() ```
Pre:
2022-06-19课堂代码
Next:
2022-05-22课件
0
likes
10
Weibo
Wechat
Tencent Weibo
QQ Zone
RenRen
Submit
Sign in
to leave a comment.
No Leanote account?
Sign up now.
0
comments
More...
Table of content
No Leanote account? Sign up now.