mirror of
https://github.com/Genymobile/scrcpy
synced 2024-12-12 18:27:16 +00:00
Fix net_send_all()
On partial writes, the final result was the number of bytes written by the last send() rather than the total.
This commit is contained in:
parent
daf90d33d5
commit
6f03022646
@ -99,16 +99,18 @@ net_send(socket_t socket, const void *buf, size_t len) {
|
||||
|
||||
ssize_t
|
||||
net_send_all(socket_t socket, const void *buf, size_t len) {
|
||||
size_t copied = 0;
|
||||
ssize_t w = 0;
|
||||
while (len > 0) {
|
||||
w = send(socket, buf, len, 0);
|
||||
if (w == -1) {
|
||||
return -1;
|
||||
return copied ? (ssize_t) copied : -1;
|
||||
}
|
||||
len -= w;
|
||||
buf = (char *) buf + w;
|
||||
copied += w;
|
||||
}
|
||||
return w;
|
||||
return copied;
|
||||
}
|
||||
|
||||
bool
|
||||
|
Loading…
Reference in New Issue
Block a user