Commit 1a1ce8b5 authored by Mikio Hara's avatar Mikio Hara

net: update documentation on methods of UDPConn

This change simplifies the documentation on methods of UDPConn and
adds a reference to golang.org/x/net/{ipv4,ipv6} packages to the
documentation on {Read,Write}MsgUDP methods.

Change-Id: I425a8d81bc46b6579aa9f89faa4982bb86b40f24
Reviewed-on: https://go-review.googlesource.com/44912
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 1080cece
...@@ -98,13 +98,7 @@ func (c *UDPConn) SyscallConn() (syscall.RawConn, error) { ...@@ -98,13 +98,7 @@ func (c *UDPConn) SyscallConn() (syscall.RawConn, error) {
return newRawConn(c.fd) return newRawConn(c.fd)
} }
// ReadFromUDP reads a UDP packet from c, copying the payload into b. // ReadFromUDP acts like ReadFrom but returns a UDPAddr.
// It returns the number of bytes copied into b and the return address
// that was on the packet.
//
// ReadFromUDP can be made to time out and return an error with
// Timeout() == true after a fixed time limit; see SetDeadline and
// SetReadDeadline.
func (c *UDPConn) ReadFromUDP(b []byte) (int, *UDPAddr, error) { func (c *UDPConn) ReadFromUDP(b []byte) (int, *UDPAddr, error) {
if !c.ok() { if !c.ok() {
return 0, nil, syscall.EINVAL return 0, nil, syscall.EINVAL
...@@ -131,11 +125,13 @@ func (c *UDPConn) ReadFrom(b []byte) (int, Addr, error) { ...@@ -131,11 +125,13 @@ func (c *UDPConn) ReadFrom(b []byte) (int, Addr, error) {
return n, addr, err return n, addr, err
} }
// ReadMsgUDP reads a packet from c, copying the payload into b and // ReadMsgUDP reads a message from c, copying the payload into b and
// the associated out-of-band data into oob. It returns the number // the associated out-of-band data into oob. It returns the number of
// of bytes copied into b, the number of bytes copied into oob, the // bytes copied into b, the number of bytes copied into oob, the flags
// flags that were set on the packet and the source address of the // that were set on the message and the source address of the message.
// packet. //
// The packages golang.org/x/net/ipv4 and golang.org/x/net/ipv6 can be
// used to manipulate IP-level socket options in oob.
func (c *UDPConn) ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *UDPAddr, err error) { func (c *UDPConn) ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *UDPAddr, err error) {
if !c.ok() { if !c.ok() {
return 0, 0, 0, nil, syscall.EINVAL return 0, 0, 0, nil, syscall.EINVAL
...@@ -147,13 +143,7 @@ func (c *UDPConn) ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *UDPAddr, ...@@ -147,13 +143,7 @@ func (c *UDPConn) ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *UDPAddr,
return return
} }
// WriteToUDP writes a UDP packet to addr via c, copying the payload // WriteToUDP acts like WriteTo but takes a UDPAddr.
// from b.
//
// WriteToUDP can be made to time out and return an error with
// Timeout() == true after a fixed time limit; see SetDeadline and
// SetWriteDeadline. On packet-oriented connections, write timeouts
// are rare.
func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (int, error) { func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (int, error) {
if !c.ok() { if !c.ok() {
return 0, syscall.EINVAL return 0, syscall.EINVAL
...@@ -181,11 +171,14 @@ func (c *UDPConn) WriteTo(b []byte, addr Addr) (int, error) { ...@@ -181,11 +171,14 @@ func (c *UDPConn) WriteTo(b []byte, addr Addr) (int, error) {
return n, err return n, err
} }
// WriteMsgUDP writes a packet to addr via c if c isn't connected, or // WriteMsgUDP writes a message to addr via c if c isn't connected, or
// to c's remote destination address if c is connected (in which case // to c's remote address if c is connected (in which case addr must be
// addr must be nil). The payload is copied from b and the associated // nil). The payload is copied from b and the associated out-of-band
// out-of-band data is copied from oob. It returns the number of // data is copied from oob. It returns the number of payload and
// payload and out-of-band bytes written. // out-of-band bytes written.
//
// The packages golang.org/x/net/ipv4 and golang.org/x/net/ipv6 can be
// used to manipulate IP-level socket options in oob.
func (c *UDPConn) WriteMsgUDP(b, oob []byte, addr *UDPAddr) (n, oobn int, err error) { func (c *UDPConn) WriteMsgUDP(b, oob []byte, addr *UDPAddr) (n, oobn int, err error) {
if !c.ok() { if !c.ok() {
return 0, 0, syscall.EINVAL return 0, 0, syscall.EINVAL
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment