Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of sticking packets in python socket

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, the editor will share with you the relevant knowledge points about how to solve the python socket sticky package problem. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.

1. Key points of file transfer:

Iterator (iterator object) is adopted to improve the efficiency of reading and access.

Conn.send line by line through for line in file_handles ()

2.socket sticky package problem:

[reason]:

In order to improve the transmission efficiency of A.TCP protocol, the sender often needs to collect quantitative data before it is encapsulated to the underlying layer and sent. If there is a continuous send (data), TCP will integrate the data (until the data buffer is full), resulting in sticky packet data.

b. The sticky packet of the receiver is due to the fact that the relevant process of the receiving user does not receive the data in time, which leads to the problem of sticking the packet. This is because the receiver first puts the received data in the system acceptance buffer, and the user process takes the quantitative data from the buffer. However, if the data in the buffer is not taken away by the user process in time before the next packet of data arrives, the next packet of data and the previous packet of partial data are in the system buffer. It may cause the process buffer set by the user to take part of the data of the two packets from the system buffer, resulting in sticky packets.

[solution]:

Before send (), the sender sends the total amount of data to the receiver and acknowledges it through both ends. The server sends the data packet, and then the receiver receives the data by setting up a buffer cycle according to the amount of data.

B: TCP provides PUSH (force data transfer immediately) operation, but affects performance

c. Comprehensive and efficient handling of sticky bags

3.code

Server.py

Client

These are all the contents of this article entitled "how to solve the python socket sticky package problem". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report