add stream mode

This commit is contained in:
skywind3000 2016-07-25 20:04:17 +08:00
parent 478275193b
commit f14622a495
2 changed files with 4 additions and 2 deletions

4
ikcp.c
View File

@ -15,6 +15,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
@ -250,6 +251,7 @@ ikcpcb* ikcp_create(IUINT32 conv, void *user)
kcp->probe = 0; kcp->probe = 0;
kcp->mtu = IKCP_MTU_DEF; kcp->mtu = IKCP_MTU_DEF;
kcp->mss = kcp->mtu - IKCP_OVERHEAD; kcp->mss = kcp->mtu - IKCP_OVERHEAD;
kcp->stream = 0;
kcp->buffer = (char*)ikcp_malloc((kcp->mtu + IKCP_OVERHEAD) * 3); kcp->buffer = (char*)ikcp_malloc((kcp->mtu + IKCP_OVERHEAD) * 3);
if (kcp->buffer == NULL) { if (kcp->buffer == NULL) {
@ -480,7 +482,7 @@ int ikcp_send(ikcpcb *kcp, const char *buffer, int len)
memcpy(seg->data, buffer, size); memcpy(seg->data, buffer, size);
} }
seg->len = size; seg->len = size;
seg->frg = count - i - 1; seg->frg = (kcp->stream == 0)? (count - i - 1) : 0;
iqueue_init(&seg->node); iqueue_init(&seg->node);
iqueue_add_tail(&seg->node, &kcp->snd_queue); iqueue_add_tail(&seg->node, &kcp->snd_queue);
kcp->nsnd_que++; kcp->nsnd_que++;

2
ikcp.h
View File

@ -298,7 +298,7 @@ struct IKCPCB
void *user; void *user;
char *buffer; char *buffer;
int fastresend; int fastresend;
int nocwnd; int nocwnd, stream;
int logmask; int logmask;
int (*output)(const char *buf, int len, struct IKCPCB *kcp, void *user); int (*output)(const char *buf, int len, struct IKCPCB *kcp, void *user);
void (*writelog)(const char *log, struct IKCPCB *kcp, void *user); void (*writelog)(const char *log, struct IKCPCB *kcp, void *user);