From 5ee659dd4115073dbf0cc9d2c381c883445c3c86 Mon Sep 17 00:00:00 2001 From: xtaci Date: Mon, 25 Jul 2016 20:14:12 +0800 Subject: [PATCH] improve network latency by introducing stream mode --- client/main.go | 1 + server/main.go | 1 + 2 files changed, 2 insertions(+) diff --git a/client/main.go b/client/main.go index 106bbeab3..3739b8337 100644 --- a/client/main.go +++ b/client/main.go @@ -231,6 +231,7 @@ func main() { } kcpconn, err := kcp.DialWithOptions(c.String("remoteaddr"), block, c.Int("datashard"), c.Int("parityshard")) checkError(err) + kcpconn.SetStreamMode(true) kcpconn.SetNoDelay(nodelay, interval, resend, nc) kcpconn.SetWindowSize(c.Int("sndwnd"), c.Int("rcvwnd")) kcpconn.SetMtu(c.Int("mtu")) diff --git a/server/main.go b/server/main.go index bd7538972..bf004fa51 100644 --- a/server/main.go +++ b/server/main.go @@ -249,6 +249,7 @@ func main() { for { if conn, err := lis.Accept(); err == nil { log.Println("remote address:", conn.RemoteAddr()) + conn.SetStreamMode(true) conn.SetNoDelay(nodelay, interval, resend, nc) conn.SetMtu(c.Int("mtu")) conn.SetWindowSize(c.Int("sndwnd"), c.Int("rcvwnd"))