OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // +build darwin freebsd linux netbsd openbsd windows | 5 // +build darwin freebsd linux netbsd openbsd windows |
6 | 6 |
7 // TCP sockets | 7 // TCP sockets |
8 | 8 |
9 package net | 9 package net |
10 | 10 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 return 0, syscall.EINVAL | 101 return 0, syscall.EINVAL |
102 } | 102 } |
103 return c.fd.Write(b) | 103 return c.fd.Write(b) |
104 } | 104 } |
105 | 105 |
106 // Close closes the TCP connection. | 106 // Close closes the TCP connection. |
107 func (c *TCPConn) Close() error { | 107 func (c *TCPConn) Close() error { |
108 if !c.ok() { | 108 if !c.ok() { |
109 return syscall.EINVAL | 109 return syscall.EINVAL |
110 } | 110 } |
111 » err := c.fd.Close() | 111 » return c.fd.Close() |
112 » c.fd = nil | |
113 » return err | |
114 } | 112 } |
115 | 113 |
116 // CloseRead shuts down the reading side of the TCP connection. | 114 // CloseRead shuts down the reading side of the TCP connection. |
117 // Most callers should just use Close. | 115 // Most callers should just use Close. |
118 func (c *TCPConn) CloseRead() error { | 116 func (c *TCPConn) CloseRead() error { |
119 if !c.ok() { | 117 if !c.ok() { |
120 return syscall.EINVAL | 118 return syscall.EINVAL |
121 } | 119 } |
122 return c.fd.CloseRead() | 120 return c.fd.CloseRead() |
123 } | 121 } |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 if l == nil || l.fd == nil { | 352 if l == nil || l.fd == nil { |
355 return syscall.EINVAL | 353 return syscall.EINVAL |
356 } | 354 } |
357 return setDeadline(l.fd, t) | 355 return setDeadline(l.fd, t) |
358 } | 356 } |
359 | 357 |
360 // File returns a copy of the underlying os.File, set to blocking mode. | 358 // File returns a copy of the underlying os.File, set to blocking mode. |
361 // It is the caller's responsibility to close f when finished. | 359 // It is the caller's responsibility to close f when finished. |
362 // Closing c does not affect f, and closing f does not affect c. | 360 // Closing c does not affect f, and closing f does not affect c. |
363 func (l *TCPListener) File() (f *os.File, err error) { return l.fd.dup() } | 361 func (l *TCPListener) File() (f *os.File, err error) { return l.fd.dup() } |
OLD | NEW |