LEFT | RIGHT |
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 » return err | |
113 } | 112 } |
114 | 113 |
115 // CloseRead shuts down the reading side of the TCP connection. | 114 // CloseRead shuts down the reading side of the TCP connection. |
116 // Most callers should just use Close. | 115 // Most callers should just use Close. |
117 func (c *TCPConn) CloseRead() error { | 116 func (c *TCPConn) CloseRead() error { |
118 if !c.ok() { | 117 if !c.ok() { |
119 return syscall.EINVAL | 118 return syscall.EINVAL |
120 } | 119 } |
121 return c.fd.CloseRead() | 120 return c.fd.CloseRead() |
122 } | 121 } |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 if l == nil || l.fd == nil { | 352 if l == nil || l.fd == nil { |
354 return syscall.EINVAL | 353 return syscall.EINVAL |
355 } | 354 } |
356 return setDeadline(l.fd, t) | 355 return setDeadline(l.fd, t) |
357 } | 356 } |
358 | 357 |
359 // 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. |
360 // It is the caller's responsibility to close f when finished. | 359 // It is the caller's responsibility to close f when finished. |
361 // 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. |
362 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() } |
LEFT | RIGHT |