mirror of
https://github.com/golang/go
synced 2024-11-05 14:56:10 -07:00
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>
This commit is contained in:
parent
91f2db3c57
commit
275755401d
@ -86,11 +86,10 @@ func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (int, error) {
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user