Tokio length demilited codec with Acknowledgement

I have the following code with works on the client and server . The client code just sends the frame ( even though it is using tcp_write_all ) and the Server reads the frame .

There is no ACK from the Server to the client

I want to modify this code so that the server will send an ACK on receiving the frame to the client . The client should wait for the ACK before sending the next frame.

How should I start implementing this ? Should I do a split of the tcpStream or is there a different way ?


fn write_frame(mut tcp: TcpStream, buf1: &Bytes, filename: &str) -> TcpStream {
                [current_pointer..(current_pointer + data_field_size + data_frame_length as usize)],


async fn process(stream: TcpStream, tid: u32) -> Result<(), Box<dyn Error>> {
let mut framed = LengthDelimitedCodec::builder()
        .length_field_offset(0) // length of hdr1
        .length_adjustment(0) // length of hdr2
        .num_skip(4) // leaving the header byte , Does not work if 0
while let Some(request) = {

Generally a decoder cannot initiate a write. Instead, it should return something that asks the caller to send an ACK frame.

Can you expand on that please ? How do you do that ? Any examples would help

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.