Commit 0d2c2e17 authored by Mikio Hara's avatar Mikio Hara

ipv6: update example for the use of dual stack listener

Updates golang/go#13612.

Change-Id: Ic139b6f862a2a24d549bd1f502299a7eac2f0e38
Reviewed-on: https://go-review.googlesource.com/17799Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent ba406c50
......@@ -130,7 +130,7 @@
// // error handling
// }
// dst := &net.UDPAddr{IP: group, Port: 1024}
// wcm := ipv6.ControlMessage{TrafficClass: DiffServCS7, HopLimit: 1}
// wcm := ipv6.ControlMessage{TrafficClass: 0xe0, HopLimit: 1}
// for _, ifi := range []*net.Interface{en0, en1} {
// wcm.IfIndex = ifi.Index
// if _, err := p.WriteTo(data[:n], &wcm, dst); err != nil {
......
......@@ -16,7 +16,7 @@ import (
)
func ExampleConn_markingTCP() {
ln, err := net.Listen("tcp6", "[::]:1024")
ln, err := net.Listen("tcp", "[::]:1024")
if err != nil {
log.Fatal(err)
}
......@@ -29,12 +29,14 @@ func ExampleConn_markingTCP() {
}
go func(c net.Conn) {
defer c.Close()
p := ipv6.NewConn(c)
if err := p.SetTrafficClass(0x28); err != nil { // DSCP AF11
log.Fatal(err)
}
if err := p.SetHopLimit(128); err != nil {
log.Fatal(err)
if c.RemoteAddr().(*net.TCPAddr).IP.To16() != nil && c.RemoteAddr().(*net.TCPAddr).IP.To4() == nil {
p := ipv6.NewConn(c)
if err := p.SetTrafficClass(0x28); err != nil { // DSCP AF11
log.Fatal(err)
}
if err := p.SetHopLimit(128); err != nil {
log.Fatal(err)
}
}
if _, err := c.Write([]byte("HELLO-R-U-THERE-ACK")); err != nil {
log.Fatal(err)
......
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