go - Does conn.SetDeadline() close the connection if it times out -
I have a Golong project that uses conn.SetDeadline (). If any AOP error is thrown away because the time of reading is over, then the connection is automatically turned off?
I have a setup where I have to wait a certain amount of time on a network connection for incoming output, and if the output has not come, then he has to send a quanta command. I have not designed a network app, so redesigning the protocol is not an option
Ideally, when an eof is removed due to the time of the setline line, then I awaken the gerotin I want to, but not the connection to stop
Thank you for your help!
Obviously it does not do this. My workings (okay, not the premises, but the right way to do this) was such a thing
expired: = create (chan error) buf: = make ([] byte, 32) goc () {_, Err: = conn.Read (buf) timeout & lt; - select err} () {case time.After (time.Now (+ 1000 * 1000 * 1000 * 5): // Wait for 5 seconds // read time is func () { & Lt; -timeout // To stop the leak, we must read from sem} () Case err: = & lt; -timeout: // successfully read}
Comments
Post a Comment