On Wednesday, June 5, 2019 at 10:14:22 AM UTC-4, Ian Lance Taylor wrote:
>
> On Wed, Jun 5, 2019 at 12:10 AM Kurtis Rader <kra...@skepticism.us 
> <javascript:>> wrote: 
> > 
> > On Tue, Jun 4, 2019 at 11:53 PM Inada Naoki <songof...@gmail.com 
> <javascript:>> wrote: 
> >> 
> >> conn.SetReadDeadline(time.Now()) 
> > 
> > 
> > Did you test that solution? Setting a deadline only affects "future Read 
> calls" according to the documentation. It cannot be used to timeout an 
> extant read. Which is what I would expect given the available UNIX like 
> kernel APIs. So while I have not tested this using a program written in Go 
> I would not expect it to work and the equivalent solution definitely does 
> not work in other languages I use regularly. 
>
> No, this does in fact work in Go.  I should have thought of that.  The 
> docs say, correctly, "SetReadDeadline sets the deadline for future 
> Read calls and any currently-blocked Read call." 
>
> Ian 
>

Wouldn't something like conn.SetReadDeadline(time.Unix(1,0)) or 
SetReadDeadline(time.Unix(0,1)) be better than 
conn.SetReadDeadline(time.Now()), as it won't make an unnecessary system 
call to get the current time? I'm just trying to make sure I'm not missing 
something.

William

-- 
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/e619b5d1-7c31-4a7c-9222-500a37ff189a%40googlegroups.com.

Reply via email to