| 1 |
747 |
jeremybenn |
// Copyright 2009 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.
|
| 4 |
|
|
|
| 5 |
|
|
// Unix domain sockets stubs for Plan 9
|
| 6 |
|
|
|
| 7 |
|
|
package net
|
| 8 |
|
|
|
| 9 |
|
|
import (
|
| 10 |
|
|
"os"
|
| 11 |
|
|
"time"
|
| 12 |
|
|
)
|
| 13 |
|
|
|
| 14 |
|
|
// UnixConn is an implementation of the Conn interface
|
| 15 |
|
|
// for connections to Unix domain sockets.
|
| 16 |
|
|
type UnixConn bool
|
| 17 |
|
|
|
| 18 |
|
|
// Implementation of the Conn interface - see Conn for documentation.
|
| 19 |
|
|
|
| 20 |
|
|
// Read implements the Conn Read method.
|
| 21 |
|
|
func (c *UnixConn) Read(b []byte) (n int, err error) {
|
| 22 |
|
|
return 0, os.EPLAN9
|
| 23 |
|
|
}
|
| 24 |
|
|
|
| 25 |
|
|
// Write implements the Conn Write method.
|
| 26 |
|
|
func (c *UnixConn) Write(b []byte) (n int, err error) {
|
| 27 |
|
|
return 0, os.EPLAN9
|
| 28 |
|
|
}
|
| 29 |
|
|
|
| 30 |
|
|
// Close closes the Unix domain connection.
|
| 31 |
|
|
func (c *UnixConn) Close() error {
|
| 32 |
|
|
return os.EPLAN9
|
| 33 |
|
|
}
|
| 34 |
|
|
|
| 35 |
|
|
// LocalAddr returns the local network address, a *UnixAddr.
|
| 36 |
|
|
// Unlike in other protocols, LocalAddr is usually nil for dialed connections.
|
| 37 |
|
|
func (c *UnixConn) LocalAddr() Addr {
|
| 38 |
|
|
return nil
|
| 39 |
|
|
}
|
| 40 |
|
|
|
| 41 |
|
|
// RemoteAddr returns the remote network address, a *UnixAddr.
|
| 42 |
|
|
// Unlike in other protocols, RemoteAddr is usually nil for connections
|
| 43 |
|
|
// accepted by a listener.
|
| 44 |
|
|
func (c *UnixConn) RemoteAddr() Addr {
|
| 45 |
|
|
return nil
|
| 46 |
|
|
}
|
| 47 |
|
|
|
| 48 |
|
|
// SetDeadline implements the Conn SetDeadline method.
|
| 49 |
|
|
func (c *UnixConn) SetDeadline(t time.Time) error {
|
| 50 |
|
|
return os.EPLAN9
|
| 51 |
|
|
}
|
| 52 |
|
|
|
| 53 |
|
|
// SetReadDeadline implements the Conn SetReadDeadline method.
|
| 54 |
|
|
func (c *UnixConn) SetReadDeadline(t time.Time) error {
|
| 55 |
|
|
return os.EPLAN9
|
| 56 |
|
|
}
|
| 57 |
|
|
|
| 58 |
|
|
// SetWriteDeadline implements the Conn SetWriteDeadline method.
|
| 59 |
|
|
func (c *UnixConn) SetWriteDeadline(t time.Time) error {
|
| 60 |
|
|
return os.EPLAN9
|
| 61 |
|
|
}
|
| 62 |
|
|
|
| 63 |
|
|
// ReadFrom implements the PacketConn ReadFrom method.
|
| 64 |
|
|
func (c *UnixConn) ReadFrom(b []byte) (n int, addr Addr, err error) {
|
| 65 |
|
|
err = os.EPLAN9
|
| 66 |
|
|
return
|
| 67 |
|
|
}
|
| 68 |
|
|
|
| 69 |
|
|
// WriteTo implements the PacketConn WriteTo method.
|
| 70 |
|
|
func (c *UnixConn) WriteTo(b []byte, addr Addr) (n int, err error) {
|
| 71 |
|
|
err = os.EPLAN9
|
| 72 |
|
|
return
|
| 73 |
|
|
}
|
| 74 |
|
|
|
| 75 |
|
|
// DialUnix connects to the remote address raddr on the network net,
|
| 76 |
|
|
// which must be "unix" or "unixgram". If laddr is not nil, it is used
|
| 77 |
|
|
// as the local address for the connection.
|
| 78 |
|
|
func DialUnix(net string, laddr, raddr *UnixAddr) (c *UnixConn, err error) {
|
| 79 |
|
|
return nil, os.EPLAN9
|
| 80 |
|
|
}
|
| 81 |
|
|
|
| 82 |
|
|
// UnixListener is a Unix domain socket listener.
|
| 83 |
|
|
// Clients should typically use variables of type Listener
|
| 84 |
|
|
// instead of assuming Unix domain sockets.
|
| 85 |
|
|
type UnixListener bool
|
| 86 |
|
|
|
| 87 |
|
|
// ListenUnix announces on the Unix domain socket laddr and returns a Unix listener.
|
| 88 |
|
|
// Net must be "unix" (stream sockets).
|
| 89 |
|
|
func ListenUnix(net string, laddr *UnixAddr) (l *UnixListener, err error) {
|
| 90 |
|
|
return nil, os.EPLAN9
|
| 91 |
|
|
}
|
| 92 |
|
|
|
| 93 |
|
|
// Accept implements the Accept method in the Listener interface;
|
| 94 |
|
|
// it waits for the next call and returns a generic Conn.
|
| 95 |
|
|
func (l *UnixListener) Accept() (c Conn, err error) {
|
| 96 |
|
|
return nil, os.EPLAN9
|
| 97 |
|
|
}
|
| 98 |
|
|
|
| 99 |
|
|
// Close stops listening on the Unix address.
|
| 100 |
|
|
// Already accepted connections are not closed.
|
| 101 |
|
|
func (l *UnixListener) Close() error {
|
| 102 |
|
|
return os.EPLAN9
|
| 103 |
|
|
}
|
| 104 |
|
|
|
| 105 |
|
|
// Addr returns the listener's network address.
|
| 106 |
|
|
func (l *UnixListener) Addr() Addr { return nil }
|