Skip to content

Commit

Permalink
net: BUG section for ReadFrom, ReadFromIP methods of IPConn on "ip4" …
Browse files Browse the repository at this point in the history
…network

Fixes #3944.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13263043
  • Loading branch information
cixtor committed Aug 28, 2013
1 parent d595b67 commit a8b4a1e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pkg/net/ipraw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func TestPacketConnICMPEcho(t *testing.T) {
if _, _, err := c.ReadFrom(rb); err != nil {
t.Fatalf("PacketConn.ReadFrom failed: %v", err)
}
// TODO: fix issue 3944
// See BUG section.
//if net == "ip4" {
// rb = ipv4Payload(rb)
//}
Expand Down
12 changes: 12 additions & 0 deletions src/pkg/net/iprawsock_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ import (
"time"
)

// BUG(mikio): On every POSIX platform, reads from the "ip4" network
// using the ReadFrom or ReadFromIP method might not return a complete
// IPv4 packet, including its header, even if there is space
// available. This can occur even in cases where Read or ReadMsgIP
// could return a complete packet. For this reason, it is recommended
// that you do not uses these methods if it is important to receive a
// full packet.
//
// The Go 1 compatibliity guidelines make it impossible for us to
// change the behavior of these methods; use Read or ReadMsgIP
// instead.

func sockaddrToIP(sa syscall.Sockaddr) Addr {
switch sa := sa.(type) {
case *syscall.SockaddrInet4:
Expand Down

0 comments on commit a8b4a1e

Please sign in to comment.