-
background
Issue Description:I'm developing a large file transfer demo using MSQuic to compare transmission efficiency with TCP. After establishing the connection, I'm using the following loop structure: while (true) {
file.read(reinterpret_cast<char*>(buffer.data()), buffer.size());
size_t bytesRead = file.gcount();
if (bytesRead > 0) {
QUIC_STATUS status = msQuic_->StreamSend(
stream_,
buffer,
1,
flags,
buffer);
if (QUIC_FAILED(status)) {
LOGE("Failed to send data chunk");
break;
}
}
std::this_thread::sleep_for(milliseconds(10));
} Problem:I must add a 10ms sleep after each 4096-byte chunk send to ensure file integrity. Request:How can I optimize sending efficiency while guaranteeing buffer stability? Specifically: What mechanisms in MSQuic can prevent send buffer overflow? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You can't reuse your buffer object for a new send until the previous send complete. Use a unique buffer to simplify things. |
Beta Was this translation helpful? Give feedback.
-
Every time data is read using a unique buffer for reading file data and passed to SendData(),but the running result shows the server still has massive packet loss, receiving only about 5% of the data. quesion
send data loop
|
Beta Was this translation helpful? Give feedback.
Hi,
There is some documentation to help you here: https://github.com/microsoft/msquic/blob/main/docs/Streams.md#sending
This sample should also help: https://github.com/microsoft/msquic/blob/main/src/tools/post/post.cpp
To get you started, the important bits are:
SendReady
QUIC_STREAM_EVENT_SEND_COMPLETE
SendReady
StreamSend
with some dataSendReady
SendReady
Note that MsQuic notifies
QUIC_STREAM_EVENT_SEND_COMPLETE
as soon as it is ready for you to give more da…