1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build darwin freebsd linux netbsd openbsd windows
7 // Base posix socket functions.
21 func (c *conn) ok() bool { return c != nil && c.fd != nil }
23 // Implementation of the Conn interface - see Conn for documentation.
25 // Read implements the Conn Read method.
26 func (c *conn) Read(b []byte) (int, error) {
28 return 0, syscall.EINVAL
33 // Write implements the Conn Write method.
34 func (c *conn) Write(b []byte) (int, error) {
36 return 0, syscall.EINVAL
41 // LocalAddr returns the local network address.
42 func (c *conn) LocalAddr() Addr {
49 // RemoteAddr returns the remote network address.
50 func (c *conn) RemoteAddr() Addr {
57 // SetDeadline implements the Conn SetDeadline method.
58 func (c *conn) SetDeadline(t time.Time) error {
62 return setDeadline(c.fd, t)
65 // SetReadDeadline implements the Conn SetReadDeadline method.
66 func (c *conn) SetReadDeadline(t time.Time) error {
70 return setReadDeadline(c.fd, t)
73 // SetWriteDeadline implements the Conn SetWriteDeadline method.
74 func (c *conn) SetWriteDeadline(t time.Time) error {
78 return setWriteDeadline(c.fd, t)
81 // SetReadBuffer sets the size of the operating system's
82 // receive buffer associated with the connection.
83 func (c *conn) SetReadBuffer(bytes int) error {
87 return setReadBuffer(c.fd, bytes)
90 // SetWriteBuffer sets the size of the operating system's
91 // transmit buffer associated with the connection.
92 func (c *conn) SetWriteBuffer(bytes int) error {
96 return setWriteBuffer(c.fd, bytes)
99 // File returns a copy of the underlying os.File, set to blocking mode.
100 // It is the caller's responsibility to close f when finished.
101 // Closing c does not affect f, and closing f does not affect c.
102 func (c *conn) File() (f *os.File, err error) { return c.fd.dup() }
104 // Close closes the connection.
105 func (c *conn) Close() error {
107 return syscall.EINVAL