瀏覽代碼

go.net/ipv6: add deadline methods to PacketConn

Update golang/go#5538

R=dave, r
CC=golang-dev
https://golang.org/cl/10089046
Mikio Hara 12 年之前
父節點
當前提交
2c0845256f
共有 1 個文件被更改,包括 29 次插入1 次删除
  1. 29 1
      ipv6/endpoint.go

+ 29 - 1
ipv6/endpoint.go

@@ -7,6 +7,7 @@ package ipv6
 import (
 	"net"
 	"syscall"
+	"time"
 )
 
 // A Conn represents a network endpoint that uses IPv6 transport.
@@ -72,12 +73,39 @@ func (c *PacketConn) SetControlMessage(cf ControlFlags, on bool) error {
 	return setControlMessage(fd, &c.payloadHandler.rawOpt, cf, on)
 }
 
+// SetDeadline sets the read and write deadlines associated with the
+// endpoint.
+func (c *PacketConn) SetDeadline(t time.Time) error {
+	if !c.payloadHandler.ok() {
+		return syscall.EINVAL
+	}
+	return c.payloadHandler.SetDeadline(t)
+}
+
+// SetReadDeadline sets the read deadline associated with the
+// endpoint.
+func (c *PacketConn) SetReadDeadline(t time.Time) error {
+	if !c.payloadHandler.ok() {
+		return syscall.EINVAL
+	}
+	return c.payloadHandler.SetReadDeadline(t)
+}
+
+// SetWriteDeadline sets the write deadline associated with the
+// endpoint.
+func (c *PacketConn) SetWriteDeadline(t time.Time) error {
+	if !c.payloadHandler.ok() {
+		return syscall.EINVAL
+	}
+	return c.payloadHandler.SetWriteDeadline(t)
+}
+
 // Close closes the endpoint.
 func (c *PacketConn) Close() error {
 	if !c.payloadHandler.ok() {
 		return syscall.EINVAL
 	}
-	return c.payloadHandler.PacketConn.Close()
+	return c.payloadHandler.Close()
 }
 
 // NewPacketConn returns a new PacketConn using c as its underlying