We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
listener.Accept() runs only after a byte is received: but expected to run it after kcp.Dial.
The test code:
package main import ( "log" "time" kcp "github.com/xtaci/kcp-go/v5" ) func main() { // start the server ln, err := kcp.Listen("127.0.0.1:48000") log.Println("Listening KCP...") if err != nil { panic(err) } // run the client go client() /** Listening for a connection **/ _, err = ln.Accept() if err != nil { panic(err) } else { log.Println("OK.") } } func client() { // wait for server to become ready time.Sleep(time.Second) // dial to the echo server if sess, err := kcp.Dial("127.0.0.1:48000"); err == nil { // wait for data write time.Sleep(time.Second) data := "." log.Println("sent:", data[:1]) if _, err := sess.Write([]byte(data[:1])); err != nil { log.Fatal(err) } } else { log.Fatal(err) } }
Output:
$ go run examples/main.go 2022/06/04 12:36:33 Listening KCP... 2022/06/04 12:36:35 sent: . 2022/06/04 12:36:35 OK.
Expected "OK." to follow right after "Listening KCP..."
The text was updated successfully, but these errors were encountered:
Test code for TCP:
package main import ( "net" "log" "time" //kcp "github.com/xtaci/kcp-go/v5" ) func main() { // start the server ln, err := net.Listen("tcp", "127.0.0.1:48000") log.Println("Listening KCP...") if err != nil { panic(err) } // run the client go client() /** Listening for a connection **/ _, err = ln.Accept() if err != nil { panic(err) } else { log.Println("OK.") } } func client() { // wait for server to become ready time.Sleep(time.Second) // dial to the echo server if sess, err := net.Dial("tcp", "127.0.0.1:48000"); err == nil { // wait for data write time.Sleep(time.Second) data := "." log.Println("sent:", data[:1]) if _, err := sess.Write([]byte(data[:1])); err != nil { log.Fatal(err) } } else { log.Fatal(err) } }
$ go run examples/main.go 2022/06/04 12:39:52 Listening KCP... 2022/06/04 12:39:53 OK.
Sorry, something went wrong.
No branches or pull requests
listener.Accept() runs only after a byte is received: but expected to run it after kcp.Dial.
The test code:
Output:
Expected "OK." to follow right after "Listening KCP..."
The text was updated successfully, but these errors were encountered: