1 // 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.
5 // Unix domain sockets stubs for Plan 9
14 // UnixConn is an implementation of the Conn interface
15 // for connections to Unix domain sockets.
18 // Implementation of the Conn interface - see Conn for documentation.
20 // Read implements the net.Conn Read method.
21 func (c *UnixConn) Read(b []byte) (n int, err error) {
25 // Write implements the net.Conn Write method.
26 func (c *UnixConn) Write(b []byte) (n int, err error) {
30 // Close closes the Unix domain connection.
31 func (c *UnixConn) Close() error {
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 {
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 {
48 // SetDeadline implements the net.Conn SetDeadline method.
49 func (c *UnixConn) SetDeadline(t time.Time) error {
53 // SetReadDeadline implements the net.Conn SetReadDeadline method.
54 func (c *UnixConn) SetReadDeadline(t time.Time) error {
58 // SetWriteDeadline implements the net.Conn SetWriteDeadline method.
59 func (c *UnixConn) SetWriteDeadline(t time.Time) error {
63 // ReadFrom implements the net.PacketConn ReadFrom method.
64 func (c *UnixConn) ReadFrom(b []byte) (n int, addr Addr, err error) {
69 // WriteTo implements the net.PacketConn WriteTo method.
70 func (c *UnixConn) WriteTo(b []byte, addr Addr) (n int, err error) {
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) {
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
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) {
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) {
99 // Close stops listening on the Unix address.
100 // Already accepted connections are not closed.
101 func (l *UnixListener) Close() error {
105 // Addr returns the listener's network address.
106 func (l *UnixListener) Addr() Addr { return nil }