gpt4 book ai didi

python - 试图发送一个大文件,python 套接字

转载 作者:太空宇宙 更新时间:2023-11-03 22:59:54 24 4
gpt4 key购买 nike

我正在尝试创建从网络摄像头到其他服务器的实时流。我的问题是我得到的框架对于套接字来说太大了
我收到这个错误:

error: [Errno 10040] A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself

这是我的代码:

 import numpy as np
import cv2
import socket
import sys
import select
cap = cv2.VideoCapture(0)
address = ('localhost', 6005)
client_socket=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
print (frame)
client_socket.connect(('120.0.0.1', 6005))
client_socket.sendto(frame, address)

我知道 c,我想也许我可以创建一个指向框架的指针并逐个发送它所以我的问题是如何将此方法转换为 python,如果可能的话

最佳答案

来自 Ans :

Your image is too big to be sent in one UDP packet. You need to split the image data into several packets that are sent individually.

If you don't have a special reason to use UDP you could also use TCP by specifying socket.SOCK_STREAM instead of socket.SOCK_DGRAM. There you don't have to worry about packet sizes and ordering.

你也可以看看Ans

关于python - 试图发送一个大文件,python 套接字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21016689/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com