1 Star 5 Fork 0

LearningOS/rCore-Tutorial-v3

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ping.py 497 Bytes
一键复制 编辑 原始数据 按行查看 历史
随风 提交于 2023-02-06 19:22 . Add a udp program and a ping test script
import socket
import sys
import time
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
addr = ('localhost', 26099)
sock.bind(addr)
print("pinging...", file=sys.stderr)
while True:
buf, raddr = sock.recvfrom(4096)
print("receive: " + buf.decode("utf-8"))
buf = "this is a ping to port 6200!".encode('utf-8')
sock.sendto(buf, ("127.0.0.1", 6200))
buf = "this is a ping to reply!".encode('utf-8')
sock.sendto(buf, raddr)
time.sleep(1)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/learning-os/rCore-Tutorial-v3.git
git@gitee.com:learning-os/rCore-Tutorial-v3.git
learning-os
rCore-Tutorial-v3
rCore-Tutorial-v3
main

搜索帮助