我正在尝试以块的形式发送数据(一次20个字节),一旦所有数据发送完毕,我将尝试再次发送数据。但是我看到第二个数据正在与以前的味精附加在一起。
data_send = "Hello I am testing this feature. Just to validate whats going with this. How many bytes I send and how many data I received in one shot"
splitLen = 20 # Buffer size
for lines in range(0, len(data_send), splitLen):
outputData = data_send[lines:lines+splitLen]
self.conn.send(outputData.encode())
self.conn.send("Welcome".encode())
在客户端,我收到此消息:
Hello I am testing
Hello I am testing this feature. Just t
Hello I am testing this feature. Just to validate whats goi
Hello I am testing this feature. Just to validate whats going with
this. How ma
Hello I am testing this feature. Just to validate whats going with
this. How many bytes I send and
Hello I am testing this feature. Just to validate whats going with
this. How many bytes I send and how many data I rece
Hello I am testing this feature. Just to validate whats going with
this. How many bytes I send and how many data I received in one shot
威尔 您好,我正在测试此功能。只是为了验证发生了什么 这个。我一次发送多少个字节,收到多少个数据
Welcome
根据我的期望,我应该只收到此消息(以上突出显示的行不应属于o / p)
Hello I am testing
Hello I am testing this feature. Just t
Hello I am testing this feature. Just to validate whats goi
Hello I am testing this feature. Just to validate whats going with this.
How ma
Hello I am testing this feature. Just to validate whats going with this.
How many bytes I send and
Hello I am testing this feature. Just to validate whats going with this.
How many bytes I send and how many data I rece
Hello I am testing this feature. Just to validate whats going with this.
How many bytes I send and how many data I received in one shot
Welcome