net: add shutdown: TCPConn.CloseWrite and CloseRead
R=golang-dev, rsc, iant
CC=golang-dev
https://golang.org/cl/5136052
diff --git a/src/pkg/net/fd.go b/src/pkg/net/fd.go
index 9084e88..a0c56f7 100644
--- a/src/pkg/net/fd.go
+++ b/src/pkg/net/fd.go
@@ -358,6 +358,22 @@
return nil
}
+func (fd *netFD) CloseRead() os.Error {
+ if fd == nil || fd.sysfile == nil {
+ return os.EINVAL
+ }
+ syscall.Shutdown(fd.sysfd, syscall.SHUT_RD)
+ return nil
+}
+
+func (fd *netFD) CloseWrite() os.Error {
+ if fd == nil || fd.sysfile == nil {
+ return os.EINVAL
+ }
+ syscall.Shutdown(fd.sysfd, syscall.SHUT_WR)
+ return nil
+}
+
func (fd *netFD) Read(p []byte) (n int, err os.Error) {
if fd == nil {
return 0, os.EINVAL