net: fix WriteTo on Plan 9
This change excludes internal UDP header size from a result of number of
bytes written on WriteTo.
Change-Id: I847d57f7f195657b6f14efdf1b4cfab13d4490dd
Reviewed-on: https://go-review.googlesource.com/9196
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
diff --git a/src/net/udpsock_plan9.go b/src/net/udpsock_plan9.go
index 4749dab..8acbb20 100644
--- a/src/net/udpsock_plan9.go
+++ b/src/net/udpsock_plan9.go
@@ -86,11 +86,10 @@
buf := make([]byte, udpHeaderSize+len(b))
i := copy(buf, h.Bytes())
copy(buf[i:], b)
- n, err := c.fd.data.Write(buf)
- if err != nil {
- err = &OpError{Op: "write", Net: c.fd.dir, Addr: addr, Err: err}
+ if _, err := c.fd.data.Write(buf); err != nil {
+ return 0, &OpError{Op: "write", Net: c.fd.dir, Addr: addr, Err: err}
}
- return n, err
+ return len(b), nil
}
// WriteTo implements the PacketConn WriteTo method.