Next advances the Reader to the next packet in the input, which will then be available through the Packet method. It returns false when the Reader stops, either by reaching the end of the input or an error. After Next returns false, the Err method will return any error that occured while reading, ex
()
| 131 | // error that occured while reading, except that if it was io.EOF, Err |
| 132 | // will return nil. |
| 133 | func (r *Reader) Next() bool { |
| 134 | hdr := struct { |
| 135 | Sec uint32 |
| 136 | SubSec uint32 |
| 137 | Len uint32 |
| 138 | OrigLen uint32 |
| 139 | }{} |
| 140 | |
| 141 | if err := binary.Read(r.r, r.order, &hdr); err != nil { |
| 142 | r.err = err |
| 143 | return false |
| 144 | } |
| 145 | |
| 146 | bs := make([]byte, hdr.Len) |
| 147 | if _, err := io.ReadFull(r.r, bs); err != nil { |
| 148 | r.err = err |
| 149 | return false |
| 150 | } |
| 151 | |
| 152 | r.pkt = &Packet{ |
| 153 | Timestamp: time.Unix(int64(hdr.Sec), r.tmult*int64(hdr.SubSec)), |
| 154 | Length: int(hdr.OrigLen), |
| 155 | Bytes: bs, |
| 156 | } |
| 157 | return true |
| 158 | } |