From f14622a49542a165feab9a37a6d8bc305af75121 Mon Sep 17 00:00:00 2001 From: skywind3000 Date: Mon, 25 Jul 2016 20:04:17 +0800 Subject: [PATCH] add stream mode --- ikcp.c | 4 +++- ikcp.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ikcp.c b/ikcp.c index 2824cd8..fc2e5eb 100644 --- a/ikcp.c +++ b/ikcp.c @@ -15,6 +15,7 @@ #include #include #include +#include @@ -250,6 +251,7 @@ ikcpcb* ikcp_create(IUINT32 conv, void *user) kcp->probe = 0; kcp->mtu = IKCP_MTU_DEF; kcp->mss = kcp->mtu - IKCP_OVERHEAD; + kcp->stream = 0; kcp->buffer = (char*)ikcp_malloc((kcp->mtu + IKCP_OVERHEAD) * 3); if (kcp->buffer == NULL) { @@ -480,7 +482,7 @@ int ikcp_send(ikcpcb *kcp, const char *buffer, int len) memcpy(seg->data, buffer, size); } seg->len = size; - seg->frg = count - i - 1; + seg->frg = (kcp->stream == 0)? (count - i - 1) : 0; iqueue_init(&seg->node); iqueue_add_tail(&seg->node, &kcp->snd_queue); kcp->nsnd_que++; diff --git a/ikcp.h b/ikcp.h index 42cee60..9167236 100644 --- a/ikcp.h +++ b/ikcp.h @@ -298,7 +298,7 @@ struct IKCPCB void *user; char *buffer; int fastresend; - int nocwnd; + int nocwnd, stream; int logmask; int (*output)(const char *buf, int len, struct IKCPCB *kcp, void *user); void (*writelog)(const char *log, struct IKCPCB *kcp, void *user);