When there is no data in tcp connection,   net.Conn.Read   will block.

Then I want to cancel the net.Conn.Read  from another goroutine,   But I do 
not want to close the connection, Because I will reuse it latter. How to 
write the code???

 For example:





func (p *proxy) toClient(ctx context.Context, conn net.Conn) {

for {
               // block here
n, err := conn.Read(buff)
               //.... handle something
}
}

func main() {
        //... build connection
        go toClient(ctx, conn)
       
        //... Then I want to cancel above block read and reuse the conn,  
How to write????
        cancle()
        reuse(conn)
}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e08956ee-6596-4ca3-a789-a6b5d3cc2f93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to