net.Listen("tcp", "localhost:4242") if err != nil { log.Fatal(err) } Open a net.Listener. Never block in the Accept loop. for { conn, err := l.Accept() if err != nil { log.Fatal(err) } go serviceConn(conn) } Call Accept in a loop, and start new goroutines for each Conn.
:= tls.Server(prefixConn{ Reader: io.MultiReader(&buf, conn), Conn: conn, }, config) Wrap the net.Conn with tls.Server. proxyConn(c, "gophercon.com:http") Service the wrapped plaintext connection. tls.Conn is a net.Conn wrapper. It takes care of handshake and de/encryption.