1 // Copyright 2017 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.
12 // BUG(tmm1): On Windows, the Write method of syscall.RawConn
13 // does not integrate with the runtime's network poller. It cannot
14 // wait for the connection to become writeable, and does not respect
15 // deadlines. If the user-provided callback returns false, the Write
16 // method will fail immediately.
18 // BUG(mikio): On JS and Plan 9, the Control, Read and Write
19 // methods of syscall.RawConn are not implemented.
25 func (c
*rawConn
) ok() bool { return c
!= nil && c
.fd
!= nil }
27 func (c
*rawConn
) Control(f
func(uintptr)) error
{
31 err
:= c
.fd
.pfd
.RawControl(f
)
32 runtime
.KeepAlive(c
.fd
)
34 err
= &OpError
{Op
: "raw-control", Net
: c
.fd
.net
, Source
: nil, Addr
: c
.fd
.laddr
, Err
: err
}
39 func (c
*rawConn
) Read(f
func(uintptr) bool) error
{
43 err
:= c
.fd
.pfd
.RawRead(f
)
44 runtime
.KeepAlive(c
.fd
)
46 err
= &OpError
{Op
: "raw-read", Net
: c
.fd
.net
, Source
: c
.fd
.laddr
, Addr
: c
.fd
.raddr
, Err
: err
}
51 func (c
*rawConn
) Write(f
func(uintptr) bool) error
{
55 err
:= c
.fd
.pfd
.RawWrite(f
)
56 runtime
.KeepAlive(c
.fd
)
58 err
= &OpError
{Op
: "raw-write", Net
: c
.fd
.net
, Source
: c
.fd
.laddr
, Addr
: c
.fd
.raddr
, Err
: err
}
63 func newRawConn(fd
*netFD
) (*rawConn
, error
) {
64 return &rawConn
{fd
: fd
}, nil
67 type rawListener
struct {
71 func (l
*rawListener
) Read(func(uintptr) bool) error
{
75 func (l
*rawListener
) Write(func(uintptr) bool) error
{
79 func newRawListener(fd
*netFD
) (*rawListener
, error
) {
80 return &rawListener
{rawConn
{fd
: fd
}}, nil