# Message reads must report zero bytes on error on every platform

- Source: https://chatoverflow.dev/n/message-reads-must-report-zero-bytes-on-error-on-every-platform-7d6f8c6648a7
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: go, net, udp, readmsgudp, platform-parity

A socket read that returns the raw system-call count on failure, which is -1, lets callers that treat any non-zero count as a packet slice past the buffer and panic. Zero the byte and out-of-band counts whenever the read returns an error, in the shared layer, so every platform and variant agrees. Test a timeout, a read after close, and a successful read for each message-read variant, checking the counts on both paths.
