Commit 0436b162 authored by Mikio Hara's avatar Mikio Hara

net: improve ExampleUDPConn_WriteTo docs

Also updates comment on isConnected field of netFD for clarification.

Change-Id: Icb1b0332e3b4c7802eae00ddc26cd5ba54c82dc2
Reviewed-on: https://go-review.googlesource.com/120955
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent a12c1f26
...@@ -121,7 +121,8 @@ func ExampleIPv4Mask() { ...@@ -121,7 +121,8 @@ func ExampleIPv4Mask() {
} }
func ExampleUDPConn_WriteTo() { func ExampleUDPConn_WriteTo() {
// Create connection in non-pre-connected state // Unlike Dial, ListenPacket creates a connection without any
// association with peers.
conn, err := net.ListenPacket("udp", ":0") conn, err := net.ListenPacket("udp", ":0")
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
...@@ -133,7 +134,7 @@ func ExampleUDPConn_WriteTo() { ...@@ -133,7 +134,7 @@ func ExampleUDPConn_WriteTo() {
log.Fatal(err) log.Fatal(err)
} }
// Write data to the desired address // The connection can write data to the desired address.
_, err = conn.WriteTo([]byte("data"), dst) _, err = conn.WriteTo([]byte("data"), dst)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
......
...@@ -22,7 +22,7 @@ type netFD struct { ...@@ -22,7 +22,7 @@ type netFD struct {
// immutable until Close // immutable until Close
family int family int
sotype int sotype int
isConnected bool isConnected bool // handshake completed or use of association with peer
net string net string
laddr Addr laddr Addr
raddr Addr raddr Addr
......
...@@ -32,7 +32,7 @@ type netFD struct { ...@@ -32,7 +32,7 @@ type netFD struct {
// immutable until Close // immutable until Close
family int family int
sotype int sotype int
isConnected bool isConnected bool // handshake completed or use of association with peer
net string net string
laddr Addr laddr Addr
raddr Addr raddr Addr
......
...@@ -50,7 +50,7 @@ type netFD struct { ...@@ -50,7 +50,7 @@ type netFD struct {
// unused // unused
pfd poll.FD pfd poll.FD
isConnected bool isConnected bool // handshake completed or use of association with peer
} }
// socket returns a network file descriptor that is ready for // socket returns a network file descriptor that is ready for
......
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