-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not working with kcp golang server #21
Comments
|
Tried it with the minimal example, I just use listen without the encryption example but no luck. package main
import (
"fmt"
"io"
"log"
"net"
"time"
"github.com/xtaci/kcp-go/v5"
)
func main() {
// key := pbkdf2.Key([]byte("demo pass"), []byte("demo salt"), 1024, 32, sha1.New)
// block, _ := kcp.NewAESBlockCrypt(key)
if listener, err := kcp.Listen("localhost:11000"); err == nil {
// spin-up the client
//go client()
for {
fmt.Println("awaiting connection")
s, err := listener.Accept()
if err != nil {
log.Fatal(err)
}
go handleEcho(s)
}
} else {
log.Fatal(err)
}
}
// handleEcho send back everything it received
func handleEcho(conn net.Conn) {
fmt.Println("new client")
buf := make([]byte, 4096)
for {
n, err := conn.Read(buf)
fmt.Println("read!!")
if err != nil {
log.Println(err)
return
}
n, err = conn.Write(buf[:n])
if err != nil {
log.Println(err)
return
}
}
} |
Oh found the fix! I just remove the ip address in golang server and just leave the port number just like this ":11000" and it works, not sure what's the difference as I'm fairly new to backend stuff. Btw does this project ready for production use in unity3D? |
Im facing the same problem as yours.And I follow your fix to remove the ipAddress,it works. |
I tried the example on this project but it seems the kcp for golang doesn’t work. Tried sending a message from this c# script but golang server won’t recognize it.
The text was updated successfully, but these errors were encountered: