Net/http Accept() blocks whole program on Linux

Hello! :slightly_smiling_face:
I am currently working on some open source project I forked
( https://github.com/sagneta/go-rtsengine )
but the code from github stops on this piece of code:

listener, err := net.Listen(“tcp”, “localhost:8082”)
if err != nil {
return err
}
fmt.Printf(“1”) //Prints 1
conn, err := listener.Accept()
fmt.Printf(“2”) //Never prints 2

I am new in Go, and quite confused, what should be done now. Should I change library from standard one, or maybe downgrade Go version?
My current version is go1.10.2 linux/amd64, and I am using Manjaro Linux.
I will be highly gratefull for any help!

Well, listener.Accept() will wait until there is an incomming TCP connection on port 8082.

So connect to that port and your program will continue.

type Listener interface {
        // Accept waits for and returns the next connection to the listener.
        Accept() (Conn, error)
        // [...]
}
2 Likes

Thank you very much!
That was silly, but I would stop there without your help :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.