mirror of
https://github.com/skywind3000/kcp.git
synced 2025-01-13 20:02:53 +08:00
new comment
This commit is contained in:
parent
71ab98f0d3
commit
d353c1afc2
6
ikcp.c
6
ikcp.c
@ -340,7 +340,7 @@ void ikcp_release(ikcpcb *kcp)
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// recv data
|
||||
// user/upper level recv: returns size, returns below zero for EAGAIN
|
||||
//---------------------------------------------------------------------
|
||||
int ikcp_recv(ikcpcb *kcp, char *buffer, int len)
|
||||
{
|
||||
@ -423,7 +423,7 @@ int ikcp_recv(ikcpcb *kcp, char *buffer, int len)
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// send data
|
||||
// peek data size
|
||||
//---------------------------------------------------------------------
|
||||
int ikcp_peeksize(const ikcpcb *kcp)
|
||||
{
|
||||
@ -451,7 +451,7 @@ int ikcp_peeksize(const ikcpcb *kcp)
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// send data
|
||||
// user/upper level send, returns below zero for error
|
||||
//---------------------------------------------------------------------
|
||||
int ikcp_send(ikcpcb *kcp, const char *buffer, int len)
|
||||
{
|
||||
|
17
ikcp.h
17
ikcp.h
@ -335,12 +335,25 @@ ikcpcb* ikcp_create(IUINT32 conv, void *user);
|
||||
// release kcp control object
|
||||
void ikcp_release(ikcpcb *kcp);
|
||||
|
||||
// user/upper level recv: returns size, returns below zero for EAGAIN
|
||||
int ikcp_recv(ikcpcb *kcp, char *buffer, int len);
|
||||
|
||||
// user/upper level send, returns below zero for error
|
||||
int ikcp_send(ikcpcb *kcp, const char *buffer, int len);
|
||||
|
||||
// update state (call it repeatedly, every 10ms-100ms)
|
||||
// update state (call it repeatedly, every 10ms-100ms), or you can ask
|
||||
// ikcp_check when to call it again (without low level packet input).
|
||||
// 'current' - current timestamp in millisec
|
||||
void ikcp_update(ikcpcb *kcp, IUINT32 current);
|
||||
|
||||
// Determine when should you invoke ikcp_update:
|
||||
// if there is no incoming low level packet, you can invoke ikcp_update
|
||||
// after millisecs ikcp_check returns, instead of call update repeatly.
|
||||
// It is important to reduce unnacessary ikcp_update calling. you can
|
||||
// just call ikcp_update in a very small interval, or you can use it to
|
||||
// schedule ikcp_update invoking (eg. when you are implementing an epoll
|
||||
// like mechanism, or optimize ikcp_update when handling massive kcp
|
||||
// connections)
|
||||
IUINT32 ikcp_check(const ikcpcb *kcp, IUINT32 current);
|
||||
|
||||
// when you received a low level packet (eg. UDP packet), call it
|
||||
@ -349,7 +362,7 @@ void ikcp_flush(ikcpcb *kcp);
|
||||
|
||||
int ikcp_peeksize(const ikcpcb *kcp);
|
||||
|
||||
// change MTU size, default is 14000
|
||||
// change MTU size, default is 1400
|
||||
int ikcp_setmtu(ikcpcb *kcp, int mtu);
|
||||
|
||||
// set maximum window size: sndwnd=32, rcvwnd=32 by default
|
||||
|
4
test.cpp
4
test.cpp
@ -137,7 +137,7 @@ void test(int mode)
|
||||
next++;
|
||||
sumrtt += rtt;
|
||||
count++;
|
||||
if (rtt > maxrtt) maxrtt = rtt;
|
||||
if (rtt > (IUINT32)maxrtt) maxrtt = rtt;
|
||||
|
||||
printf("[RECV] mode=%d sn=%d rtt=%d\n", mode, (int)sn, (int)rtt);
|
||||
}
|
||||
@ -150,7 +150,7 @@ void test(int mode)
|
||||
ikcp_release(kcp2);
|
||||
|
||||
const char *names[3] = { "default", "normal", "fast" };
|
||||
printf("%s mode result (%dms):\n", names[mode], ts1);
|
||||
printf("%s mode result (%dms):\n", names[mode], (int)ts1);
|
||||
printf("avgrtt=%d maxrtt=%d\n", (int)(sumrtt / count), maxrtt);
|
||||
printf("press enter to next ...\n");
|
||||
char ch; scanf("%c", &ch);
|
||||
|
Loading…
Reference in New Issue
Block a user