// SendReadTimeout instructs the peer to simulate a read timeout. It then waits
// for acknowledgement of the timeout, buffering any packets received since
// then. The packets are then returned.

SendReadTimeout instructs the peer to simulate a read timeout. It then waits
for acknowledgement of the timeout, buffering any packets received since
then. The packets are then returned.
// SendReadTimeout instructs the peer to simulate a read timeout . It then waits // for acknowledgement of the timeout buffering any packets received since // then . The packets are then returned .
func (p *packetAdaptor) SendReadTimeout(d time.Duration) ([][]byte, error) {
	p.log("Simulating read timeout: "+d.String(), nil)
	payload := make([]byte, 1+8)
	payload[0] = opcodeTimeout
	binary.BigEndian.PutUint64(payload[1:], uint64(d.Nanoseconds()))
	if _, err := p.Conn.Write(payload); err != nil {
		return nil, err
	}
	var packets [][]byte
	for {
		opcode, err := p.readOpcode()
		if err != nil {
			return nil, err
		}
		switch opcode {
		case opcodeTimeoutAck:
			p.log("Received timeout ACK", nil)
			return packets, nil
		case opcodePacket:
			packet, err := p.readPacketBody()
			if err != nil {
				return nil, err
			}
			p.log("Simulating dropped packet", packet)
			packets = append(packets, packet)
		default:
			return nil, fmt.Errorf("unexpected opcode '%d'", opcode)
		}
	}
}
func ( p * packetAdaptor ) SendReadTimeout ( d time . Duration ) ( [ ] [ ] byte , error ) { p . log ( " " + d . String ( ) , nil ) payload := make ( [ ] byte , 1 + 8 ) payload [ 0 ] = opcodeTimeout binary . BigEndian . PutUint64 ( payload [ 1 : ] , uint64 ( d . Nanoseconds ( ) ) ) if _ , err := p . Conn . Write ( payload ) ; err != nil { return nil , err } var packets [ ] [ ] byte for { opcode , err := p . readOpcode ( ) if err != nil { return nil , err } switch opcode { case opcodeTimeoutAck : p . log ( " " , nil ) return packets , nil case opcodePacket : packet , err := p . readPacketBody ( ) if err != nil { return nil , err } p . log ( " " , packet ) packets = append ( packets , packet ) default : return nil , fmt . Errorf ( " " , opcode ) } } }
SendReadTimeout instructs the peer to simulate a read timeout.
SendReadTimeout instructs the peer to simulate a read timeout .
// Done! Return the packets buffered and continue.
 // Buffer the packet for the caller to process.
