func AwaitEOF(s Stream) error {
	// So we don't wait forever
	s.SetDeadline(time.Now().Add(EOFTimeout))

	// We *have* to observe the EOF. Otherwise, we leak the stream.
	// Now, technically, we should do this *before*
	// returning from SendMessage as the message
	// hasn't really been sent yet until we see the
	// EOF but we don't actually *know* what
	// protocol the other side is speaking.
	n, err := s.Read([]byte{0})
	if n > 0 || err == nil {
		s.Reset()
		return ErrExpectedEOF
	}
	if err != io.EOF {
		s.Reset()
		return err
	}
	return nil
}
func AwaitEOF(s Stream) error {
	
	s.SetDeadline(time.Now().Add(EOFTimeout))

	
	
	
	
	
	
	n, err := s.Read([]byte{0})
	if n > 0 || err == nil {
		s.Reset()
		return ErrExpectedEOF
	}
	if err != io.EOF {
		s.Reset()
		return err
	}
	return nil
}
func AwaitEOF ( s Stream ) error { // So we don't wait forever s . SetDeadline ( time . Now ( ) . Add ( EOFTimeout ) ) // We *have* to observe the EOF. Otherwise, we leak the stream. // Now, technically, we should do this *before* // returning from SendMessage as the message // hasn't really been sent yet until we see the // EOF but we don't actually *know* what // protocol the other side is speaking. n , err := s . Read ( [ ] byte { 0 } ) if n > 0 || err == nil { s . Reset ( ) return ErrExpectedEOF } if err != io . EOF { s . Reset ( ) return err } return nil }
// AwaitEOF waits for an EOF on the given stream, returning an error if that
// fails. It waits at most EOFTimeout (defaults to 1 minute) after which it
// resets the stream.
AwaitEOF waits for an EOF on the given stream returning an error if that fails . It waits at most EOFTimeout ( defaults to 1 minute ) after which it resets the stream .