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.
14 // Network file descritor.
16 proto
, name
, dir
string
21 var canCancelIO
= true // used for testing current package
26 func dialTimeout(net
, addr
string, timeout time
.Duration
) (Conn
, error
) {
27 // On plan9, use the relatively inefficient
28 // goroutine-racing implementation.
29 return dialTimeoutRace(net
, addr
, timeout
)
32 func newFD(proto
, name
string, ctl
*os
.File
, laddr
, raddr Addr
) *netFD
{
33 return &netFD
{proto
, name
, "/net/" + proto
+ "/" + name
, ctl
, nil, laddr
, raddr
}
36 func (fd
*netFD
) ok() bool { return fd
!= nil && fd
.ctl
!= nil }
38 func (fd
*netFD
) Read(b
[]byte) (n
int, err error
) {
40 return 0, syscall
.EINVAL
43 fd
.data
, err
= os
.OpenFile(fd
.dir
+"/data", os
.O_RDWR
, 0)
48 n
, err
= fd
.data
.Read(b
)
49 if fd
.proto
== "udp" && err
== io
.EOF
{
56 func (fd
*netFD
) Write(b
[]byte) (n
int, err error
) {
58 return 0, syscall
.EINVAL
61 fd
.data
, err
= os
.OpenFile(fd
.dir
+"/data", os
.O_RDWR
, 0)
66 return fd
.data
.Write(b
)
69 func (fd
*netFD
) CloseRead() error
{
76 func (fd
*netFD
) CloseWrite() error
{
83 func (fd
*netFD
) Close() error
{
99 func (fd
*netFD
) dup() (*os
.File
, error
) {
100 return nil, syscall
.EPLAN9
103 func setDeadline(fd
*netFD
, t time
.Time
) error
{
104 return syscall
.EPLAN9
107 func setReadDeadline(fd
*netFD
, t time
.Time
) error
{
108 return syscall
.EPLAN9
111 func setWriteDeadline(fd
*netFD
, t time
.Time
) error
{
112 return syscall
.EPLAN9
115 func setReadBuffer(fd
*netFD
, bytes
int) error
{
116 return syscall
.EPLAN9
119 func setWriteBuffer(fd
*netFD
, bytes
int) error
{
120 return syscall
.EPLAN9