In Go, SetReadDeadline sets a time (not a duration) on a connection; a Read that is still blocked then returns an i/o timeout error. You must set it again before each read if you want an idle timeout. See context for cancellation in general.