1 // Copyright 2015 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.
9 // BUG(mikio): On JS, NaCl and Windows, the FileConn, FileListener and
10 // FilePacketConn functions are not implemented.
14 func (fileAddr
) Network() string { return "file+net" }
15 func (f fileAddr
) String() string { return string(f
) }
17 // FileConn returns a copy of the network connection corresponding to
19 // It is the caller's responsibility to close f when finished.
20 // Closing c does not affect f, and closing f does not affect c.
21 func FileConn(f
*os
.File
) (c Conn
, err error
) {
24 err
= &OpError
{Op
: "file", Net
: "file+net", Source
: nil, Addr
: fileAddr(f
.Name()), Err
: err
}
29 // FileListener returns a copy of the network listener corresponding
30 // to the open file f.
31 // It is the caller's responsibility to close ln when finished.
32 // Closing ln does not affect f, and closing f does not affect ln.
33 func FileListener(f
*os
.File
) (ln Listener
, err error
) {
34 ln
, err
= fileListener(f
)
36 err
= &OpError
{Op
: "file", Net
: "file+net", Source
: nil, Addr
: fileAddr(f
.Name()), Err
: err
}
41 // FilePacketConn returns a copy of the packet network connection
42 // corresponding to the open file f.
43 // It is the caller's responsibility to close f when finished.
44 // Closing c does not affect f, and closing f does not affect c.
45 func FilePacketConn(f
*os
.File
) (c PacketConn
, err error
) {
46 c
, err
= filePacketConn(f
)
48 err
= &OpError
{Op
: "file", Net
: "file+net", Source
: nil, Addr
: fileAddr(f
.Name()), Err
: err
}