我试图将安装在BeagleBoneBlack(linux设备)上的摄像头的视频流式传输到服务器(Windows服务器)。 BeagleBone使用DHCP(动态IP)连接到Internet,并基本上将UDP数据包发送到服务器。在服务器端,我使用套接字实现了一个简单的Python程序,它应该可以轻松读取来自特定IP或特定端口的UDP数据包。在wireshark中,我能够看到数据包到达服务器,但python程序无法捕捉到它们。我试图听取不同的IP,如'本地主机'或特定的IP,但似乎没有任何工作。无法使用Python读取服务器上的UDP数据包
Python程序服务器端:
import socket
IP = '192.168.23.240' #IP of the BeagleBone on Wireshark
IP = '109.164.170.155' #IP of the router in which the BeagleBone is attached
IP = '0.0.0.0' #localhost
IP = '' #localhost
IP = '192.168.0.21' #IP localhost server
IP = 'localhost' #localhost
PORT = 5454
if __name__ == "__main__":
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((IP,PORT))
f = open('file.mp4','wb')
data, addr = s.recvfrom(4096)
print 'Receiving from: ' +str(addr)
for i in xrange(1000):
f.write(data)
data, addr = s.recvfrom(4096)
print 'receiving from ' + str(addr) + ' ...'
f.close()
s.close()
在Wireshark的服务器端:
如何是可能的,我能够读取Wireshark的数据包,但没有使用一个简单的Python程序?有人知道我在这里做错了什么?
是的,该程序是听本地主机,但我也尝试过IP,如127.0.0.1或Beaglebone的IP:192.168.23.240这给了我一个错误“[Errno 10049]”请求的地址无效其上下文'“。 UDP上可能有防火墙,但我不明白wireshark为什么能够读取它们。顺便说一句,我知道使用UDP发送文件不是最好的,但我只是测试连接。 – lcit