// ReadFromIP reads a IP packet from c, copying the payload into b.
// It returns the number of bytes copied into b and the return address
// that was on the packet.
//
// ReadFromIP can be made to time out and return an error with
// Timeout() == true after a fixed time limit; see SetDeadline and
// SetReadDeadline.
ReadFromIP reads a IP packet from c, copying the payload into b.
It returns the number of bytes copied into b and the return address
that was on the packet.

ReadFromIP can be made to time out and return an error with
Timeout() == true after a fixed time limit; see SetDeadline and
SetReadDeadline.
// ReadFromIP reads a IP packet from c copying the payload into b . // It returns the number of bytes copied into b and the return address // that was on the packet . // // ReadFromIP can be made to time out and return an error with // Timeout () == true after a fixed time limit ; see SetDeadline and // SetReadDeadline .
func (c *IPConn) ReadFromIP(b []byte) (int, *IPAddr, error) {
	if !c.ok() {
		return 0, nil, syscall.EINVAL
	}
	var addr *IPAddr
	n, sa, err := c.fd.ReadFrom(b)
	switch sa := sa.(type) {
	case *syscall.SockaddrInet4:
		addr = &IPAddr{sa.Addr[0:]}
		if len(b) >= IPv4len { 
			hsize := (int(b[0]) & 0xf) * 4
			copy(b, b[hsize:])
			n -= hsize
		}
	case *syscall.SockaddrInet6:
		addr = &IPAddr{sa.Addr[0:]}
	}
	return n, addr, err
}
func ( c * IPConn ) ReadFromIP ( b [ ] byte ) ( int , * IPAddr , error ) { if ! c . ok ( ) { return 0 , nil , syscall . EINVAL } var addr * IPAddr n , sa , err := c . fd . ReadFrom ( b ) switch sa := sa . ( type ) { case * syscall . SockaddrInet4 : addr = & IPAddr { sa . Addr [ 0 : ] } if len ( b ) >= IPv4len { hsize := ( int ( b [ 0 ] ) & 0xf ) * 4 copy ( b , b [ hsize : ] ) n -= hsize } case * syscall . SockaddrInet6 : addr = & IPAddr { sa . Addr [ 0 : ] } } return n , addr , err }
ReadFromIP reads a IP packet from c, copying the payload into b.
ReadFromIP reads a IP packet from c copying the payload into b .
// TODO(cw,rsc): consider using readv if we know the family // type to avoid the header trim/copy // discard ipv4 header