LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 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 // (Raw) IP sockets | 7 // (Raw) IP sockets |
8 | 8 |
9 package net | 9 package net |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 return 0, syscall.EINVAL | 76 return 0, syscall.EINVAL |
77 } | 77 } |
78 return c.fd.Write(b) | 78 return c.fd.Write(b) |
79 } | 79 } |
80 | 80 |
81 // Close closes the IP connection. | 81 // Close closes the IP connection. |
82 func (c *IPConn) Close() error { | 82 func (c *IPConn) Close() error { |
83 if !c.ok() { | 83 if !c.ok() { |
84 return syscall.EINVAL | 84 return syscall.EINVAL |
85 } | 85 } |
86 » err := c.fd.Close() | 86 » return c.fd.Close() |
87 » c.fd = nil | |
88 » return err | |
89 } | 87 } |
90 | 88 |
91 // LocalAddr returns the local network address. | 89 // LocalAddr returns the local network address. |
92 func (c *IPConn) LocalAddr() Addr { | 90 func (c *IPConn) LocalAddr() Addr { |
93 if !c.ok() { | 91 if !c.ok() { |
94 return nil | 92 return nil |
95 } | 93 } |
96 return c.fd.laddr | 94 return c.fd.laddr |
97 } | 95 } |
98 | 96 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 if err != nil { | 253 if err != nil { |
256 return nil, err | 254 return nil, err |
257 } | 255 } |
258 return newIPConn(fd), nil | 256 return newIPConn(fd), nil |
259 } | 257 } |
260 | 258 |
261 // File returns a copy of the underlying os.File, set to blocking mode. | 259 // File returns a copy of the underlying os.File, set to blocking mode. |
262 // It is the caller's responsibility to close f when finished. | 260 // It is the caller's responsibility to close f when finished. |
263 // Closing c does not affect f, and closing f does not affect c. | 261 // Closing c does not affect f, and closing f does not affect c. |
264 func (c *IPConn) File() (f *os.File, err error) { return c.fd.dup() } | 262 func (c *IPConn) File() (f *os.File, err error) { return c.fd.dup() } |
LEFT | RIGHT |