无法在Python 2.7中发送或解决UDP数据包

时间:2015-02-26 05:16:20

标签: python udp

我正在尝试将数据包发送到我的“wifi灯”照明系统(如Philips Hue)。我这里有文档描述需要使用端口8899将udp数据包发送到我的“网桥”,我有IP地址。

  

所有UDP命令都是3字节。   即将所有RGBW COLOR Wifi Lights Smart灯打开然后发送   TCP / IP UDP数据包:0x42 0x00 0x55

我能想出如何在python中做的唯一方法是将它们链接在一起,如下面的MESSAGE。 sendto()需要一个字符串,不接受hex或int。

import socket
UDP_IP1 = '192.168.0.104'
UDP_PORT = 8899
MESSAGE = str(0x410055)#0x410055

print "UDP target IP:", UDP_IP
print "UDP target port:", UDP_PORT
print "message:", MESSAGE

sock = socket.socket(socket.AF_INET, # Internet
                     socket.SOCK_DGRAM) # UDP
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))

但是我一直都会遇到这个错误。

  File "C:\3_test\wifilight_py.py", line 37, in <module>
    sock.sendto(str(e), (UDP_IP, UDP_PORT))
socket.error: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions
[Finished in 0.5s]

尽管Windows防火墙被完全禁用(Windows 7 / Python 2.7)。

我在我的智慧结束时,我不确定如何解决这个问题。我安装了Wireshark,但它提供了大量信息,没有任何相关信息。

0 个答案:

没有答案