print("等待视频流...")
packet_count = 0
while True:
data = video_sock.recv(65536)
if not data:
break
packet_count += 1
if packet_count % 10 == 0:
print(f"收到 {packet_count} 个视频包, 最新包大小: {len(data)}")
except socket.timeout:
print("连接超时,请检查服务端是否正常运行")
except Exception as e:
print(f"发生错误: {e}")
finally:
if 'video_sock' in locals():
video_sock.close()
if 'control_sock' in locals():
control_sock.close()
print("连接已关闭")
except Exception as e:
print(f"错误:{e}")
finally:
if 'video_sock' in locals():
video_sock.close()
if 'control_sock' in locals():
control_sock.close()
```