如何解决当我尝试使用套接字时 Pygame 冻结
代码:
'''pygame.init()
screen = pygame.display.set_mode((950,500))
clock = pygame.time.Clock()
max_bytes = 64000
udp_conn = socket.socket(socket.AF_INET,socket.soCK_DGRAM)
udp_conn.bind(('0.0.0.0',5000))
run = True
while run:
size_msg,address = udp_conn.recvfrom(max_bytes)
size = int.from_bytes(size_msg,byteorder='big')
while size > 10000000: # if size is greater than 10M then loop has to fire to get value of the size of
# the compressed img.
size = int.from_bytes(size_msg,byteorder='big')
pixels = recvall(size,udp_conn,max_bytes)
try:
pixels = decompress(pixels)
scrn_img = pygame.image.fromstring(str(pixels),(950,500),'RGB')
scrn_shot = pygame.transform.scale(scrn_img,500))
screen.blit(scrn_shot,(0,0))
pygame.display.flip()
clock.tick(60)
except:
pass
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
run = False
sys.exit()'''
我试图从其他计算机获取屏幕截图,然后将它们加载到屏幕上,但屏幕从一开始就没有响应,然后崩溃。有人知道为什么会崩溃吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。