mirror of
https://github.com/skywind3000/kcp.git
synced 2024-12-25 22:50:09 +08:00
ikcp_send 返回成功发送的字节数,-1 为错误,-2 为 EAGAIN
This commit is contained in:
parent
c0cb6ab3ac
commit
f2aa30ea21
13
ikcp.c
13
ikcp.c
@ -470,7 +470,7 @@ int ikcp_send(ikcpcb *kcp, const char *buffer, int len)
|
||||
{
|
||||
IKCPSEG *seg;
|
||||
int count, i;
|
||||
int append = 0;
|
||||
int sent = 0;
|
||||
|
||||
assert(kcp->mss > 0);
|
||||
if (len < 0) return -1;
|
||||
@ -498,11 +498,11 @@ int ikcp_send(ikcpcb *kcp, const char *buffer, int len)
|
||||
len -= extend;
|
||||
iqueue_del_init(&old->node);
|
||||
ikcp_segment_delete(kcp, old);
|
||||
append = extend;
|
||||
sent = extend;
|
||||
}
|
||||
}
|
||||
if (len <= 0) {
|
||||
return 0;
|
||||
return sent;
|
||||
}
|
||||
}
|
||||
|
||||
@ -510,8 +510,8 @@ int ikcp_send(ikcpcb *kcp, const char *buffer, int len)
|
||||
else count = (len + kcp->mss - 1) / kcp->mss;
|
||||
|
||||
if (count >= (int)IKCP_WND_RCV) {
|
||||
if (kcp->stream != 0 && append > 0)
|
||||
return append;
|
||||
if (kcp->stream != 0 && sent > 0)
|
||||
return sent;
|
||||
return -2;
|
||||
}
|
||||
|
||||
@ -537,9 +537,10 @@ int ikcp_send(ikcpcb *kcp, const char *buffer, int len)
|
||||
buffer += size;
|
||||
}
|
||||
len -= size;
|
||||
sent += size;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return sent;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user