Closed go-jar closed 2 years ago
Data on streams is sent immediately; there is no need to flush. Finish is only for indicating when you are permanently done sending data on that stream.
Data on streams is sent immediately; there is no need to flush. Finish is only for indicating when you are permanently done sending data on that stream.
Thanks! But server won't receive any data until client call finish(). And once the finish() is called, the send stream is terminated. So client must call conn.open_uni() or conn.open_bi() to send data again. How can client send data on the same stream and server can receive data from client every time?
Well, you're using read_to_end()
on the server, so of course the server-side reads won't give you anything until the client calls finish()
.
Well, you're using
read_to_end()
on the server, so of course the server-side reads won't give you anything until the client callsfinish()
.
Thanks! Do you mean that after client using send_to_end() to send data without calling finish(), then the server can use read() to get data immediately? I will try it.
read
will yield any available data, yeah. Note that just like TCP, write boundaries are not preserved within streams, so if you want to send discrete messages on a single stream you'll need some form of framing (e.g. tokio's LengthDelimited codec)
read
will yield any available data, yeah. Note that just like TCP, write boundaries are not preserved within streams, so if you want to send discrete messages on a single stream you'll need some form of framing (e.g. tokio's LengthDelimited codec)
Thanks!
After sending data by SendStream, I must call finish() to make peer receive data.
But I want to use the same stream to send data and peer can receive data every time. I don't know how to make it, because SendStream has no method flush(). Client:
Server: