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 data size sent by C # Socket

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Today, I will talk to you about how to solve the problem of data size sent by C# Socket. Many people may not know much about it. In order to make you understand better, the editor summarized the following content for you. I hope you can get something according to this article.

TCP/IP is a reliable transmission protocol that ensures that data can arrive at its destination in a sequential manner. Seeing the above description when writing TCP/IP applications seems to be relieved, as long as the program does not have an accident, data transmission is correct. Recently, however, the result obtained in a file transfer work is not like this. It is found that the network environment and a data transmission conference affect the whole transmission result. Here are the tests for the past two nights.

Description of the test content:

Each file block packet is about 120k.

Asynchronous 5 connection is used for transmission, and both Socket.SendBufferSize and Socket.ReceiveBufferSize are set to 64K

The test servers are:

Lan: ServerA

In American computer rooms: ServerB latency is high and Ping sometimes times out.

Test client one and surf the Internet through ADSL.

Here is how Client downloads files from Sever:

Server 8K SendBuffer, client 8K ReceiveBuffer

Download files from ServerA, download multiple files ranging from several M to hundreds of M, and the file is correct after download.

Download files from ServerB, download multiple files separately, a few M or smaller files are partly correct, and large files are basically errors. The number of bytes sent by both ends is equal to the number of bytes received, which accords with the file size, and the program does not track the protocol decomposition error caused by abnormal data reception.

Server 4K SendBuffer, client 8K ReceiveBuffer

Download files from ServerA, download multiple files ranging from several M to hundreds of M, and the file is correct after download.

Download files from ServerB, download multiple files respectively, the correct rate of files is relatively high, but there are still more errors in large files. When Thunderbolt download was started, the situation began to deteriorate, and most of the received files had problems. The number of bytes sent and received recorded at both ends were equal to the size of the file, and the program did not track the protocol decomposition error caused by abnormal data reception.

Server 2K SendBuffer, client 8K ReceiveBuffer

Download files from ServerA, download multiple files ranging from several M to hundreds of M, and the file is correct after download.

Download files from ServerB, download multiple files respectively, and no error files are found. When Thunderbolt download is started, there are still individual file errors. The number of bytes sent and received recorded at both ends are equal to the file size, and the program does not track the protocol decomposition errors caused by abnormal data reception.

Server 1K SendBuffer, client 8K ReceiveBuffer

Download files from ServerA, download multiple files ranging from several M to hundreds of M, and the file is correct after download.

Download files from ServerB, download multiple files respectively, and no error files are found. No file error was found when Thunderbolt download was started.

The situation of sending test files to Server and downloading is basically the same, which shows that it is easy to cause errors in dealing with sending large data packets in the case of bad network, but it seems that this situation does not exist when TCP/IP protocol explains that this situation does not exist, because when a sent data exceeds a certain value, TCP will divide blocks and ensure its order. However, when the network is not good, the data received by the test results are incorrect, but the size of the data processed is correct, which does not affect the decomposition of the whole protocol. Due to the lack of understanding of CP/IP protocol, lower layer and routing processing, the specific reason has not been found yet. Do not rule out that there are errors in the program that have not yet been discovered, and intend to add a check to the file data sent and then test it to see what happens.

Add to it.

Only one property was modified in the above test

TcpUtils.SendBufferLength = 1K, 2K, 4K, 8K.

However, only 1K test results strangely did not show file errors, several of them appeared only for ServerB, not for ServerA, and 2KLJ 4K only showed many errors when Xunlei was turned on.

After reading the above, do you have any further understanding of how to solve the problem of data size sent by C # Socket? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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