1

I have a client(written in Python) and a server(writted in C)

Here is part of my code for python udp client:

    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:

Name: travel Prague.mp4
Size: 1936l Prague.mp4
Port: 5008l Prague.mp4
IP: 127.0.0.1gue.mp4
IP: 127.0.0.1gue.mp4

How can i solve this problem?

4

1 回答 1

1

我终于更改了我的服务器以创建一个新的字符字符串,用于发送每个名称、大小、IP、端口并通过 UDP 发送该字符串,这解决了问题
谢谢大家!

于 2014-11-01T09:07:35.740 回答