Skip to content

Conversation

@shawwwn
Copy link

@shawwwn shawwwn commented Feb 8, 2021

kcp-go/sess.go

Lines 913 to 918 in 88fc14a

// AcceptKCP accepts a KCP connection
func (l *Listener) AcceptKCP() (*UDPSession, error) {
var timeout <-chan time.Time
if tdeadline, ok := l.rd.Load().(time.Time); ok && !tdeadline.IsZero() {
timeout = time.After(time.Until(tdeadline))
}

Here var timeout is fixed, thus subsequent calls to SetDeadline() after AcceptKCP() will not be able to change the listener's timeout.

lis.SetDeadline(time.Now().Add(10 * time.Second))		// OK
conn, _ := lis.AcceptKCP()

go func() {
	<-time.After(5 * time.Second)
	lis.SetDeadline(time.Now().Add(10 * time.Second))	// Has no effect
}()

From a naive understanding of the go document, calling SetReadDeadline() should be able to extend the deadline of the underlying connection.
https://golang.org/pkg/net/#PacketConn

@xtaci xtaci closed this Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants