我尝试设置UDP客户端,看看我是否可以打印如下数据:
import socket
target_host = "127.0.0.1"
target_port = 80
# create a socket object
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
#send some data
client.sendto("AAABBBCCC", (target_host, target_port))
#receive some data
data, addr = client.recvfrom(4096)
print data
所以我执行它 $ python udp_client.py
但是shell刚刚停留在代码中的这一行 data,addr = client.recvfrom(4096)
如何解决这个问题?