call write until all is written out
This commit is contained in:
parent
802299e69a
commit
98117a3068
|
@ -60,9 +60,9 @@ method write*(s: ChronosStream, msg: seq[byte]) {.async.} =
|
|||
return
|
||||
|
||||
withExceptions:
|
||||
# Returns 0 sometimes when write fails - but there's not much we can do here?
|
||||
if (await s.client.write(msg)) != msg.len:
|
||||
raise (ref LPStreamError)(msg: "Write couldn't finish writing")
|
||||
var writen = 0
|
||||
while (writen < msg.len):
|
||||
writen += await s.client.write(msg[writen..<msg.len]) # TODO: does the slice create a copy here?
|
||||
|
||||
method closed*(s: ChronosStream): bool {.inline.} =
|
||||
result = s.client.closed
|
||||
|
|
Loading…
Reference in New Issue