[英]Python UDP-Receive buffer being overwritten
I have a client(written in Python) and a server(writted in C) 我有一个客户端(用Python编写)和一个服务器(用C语言编写)
Here is part of my code for python udp client: 这是我的python udp客户端代码的一部分:
for x in range(noResults):
fName, addr = sock.recvfrom(1000)
print "Name:", fName
resultList[x].name=fName.strip('\x00')
fSize, addr = sock.recvfrom(1000)
print "Size:", fSize
resultList[x].size=fSize.strip('\x00')
fPort, addr = sock.recvfrom(1000)
print "Port:", fPort
resultList[x].port=fPort.strip('\x00')
fIP, addr = sock.recvfrom(1000)
print "IP:", fIP
resultList[x].ip=fIP.strip('\x00')
sys.stdout.flush()
print "IP:",resultList[x].ip
i=i+1
while the output it produces after communicating with server(written in C) is: 与服务器(用C编写)通信后产生的输出为:
Name: travel Prague.mp4 姓名:travel Prague.mp4
Size: 1936l Prague.mp4 尺寸:1936l Prague.mp4
Port: 5008l Prague.mp4 港口:5008l Prague.mp4
IP: 127.0.0.1gue.mp4 的IP:127.0.0.1gue.mp4
IP: 127.0.0.1gue.mp4 的IP:127.0.0.1gue.mp4
How can i solve this problem? 我怎么解决这个问题?
I finally changed my server to make a new char string for sending each of name,size,ip,port and send that string via UDP and that solved the problem 我终于更改了服务器,以创建一个新的char字符串来发送名称,大小,ip,端口中的每个字符串,并通过UDP发送该字符串,从而解决了问题
Thanks ALL!! 谢谢大家!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.