package poll
import "internal/poll"
Package poll supports non-blocking I/O on file descriptors with polling. This supports I/O operations that block only a goroutine, not a thread. This is used by the net and os packages. It uses a poller built into the runtime, with support from the runtime scheduler.
Index ¶
- Variables
- func IsPollDescriptor(fd uintptr) bool
- func SendFile(fd *FD, src syscall.Handle, n int64) (written int64, err error)
- type FD
- func (fd *FD) Accept(sysSocket func() (syscall.Handle, error)) (syscall.Handle, []syscall.RawSockaddrAny, uint32, string, error)
- func (fd *FD) Close() error
- func (fd *FD) ConnectEx(ra syscall.Sockaddr) error
- func (fd *FD) Fchdir() error
- func (fd *FD) Fchmod(mode uint32) error
- func (fd *FD) Fchown(uid, gid int) error
- func (fd *FD) FindNextFile(data *syscall.Win32finddata) error
- func (fd *FD) Fsync() error
- func (fd *FD) Ftruncate(size int64) error
- func (fd *FD) GetFileInformationByHandle(data *syscall.ByHandleFileInformation) error
- func (fd *FD) GetFileType() (uint32, error)
- func (fd *FD) Init(net string, pollable bool) (string, error)
- func (fd *FD) Pread(b []byte, off int64) (int, error)
- func (fd *FD) Pwrite(buf []byte, off int64) (int, error)
- func (fd *FD) RawControl(f func(uintptr)) error
- func (fd *FD) RawRead(f func(uintptr) bool) error
- func (fd *FD) RawWrite(f func(uintptr) bool) error
- func (fd *FD) Read(buf []byte) (int, error)
- func (fd *FD) ReadFrom(buf []byte) (int, syscall.Sockaddr, error)
- func (fd *FD) ReadMsg(p []byte, oob []byte) (int, int, int, syscall.Sockaddr, error)
- func (fd *FD) Seek(offset int64, whence int) (int64, error)
- func (fd *FD) SetDeadline(t time.Time) error
- func (fd *FD) SetReadDeadline(t time.Time) error
- func (fd *FD) SetWriteDeadline(t time.Time) error
- func (fd *FD) Setsockopt(level, optname int32, optval *byte, optlen int32) error
- func (fd *FD) SetsockoptIPMreq(level, name int, mreq *syscall.IPMreq) error
- func (fd *FD) SetsockoptIPv6Mreq(level, name int, mreq *syscall.IPv6Mreq) error
- func (fd *FD) SetsockoptInet4Addr(level, name int, arg [4]byte) error
- func (fd *FD) SetsockoptInt(level, name, arg int) error
- func (fd *FD) SetsockoptLinger(level, name int, l *syscall.Linger) error
- func (fd *FD) Shutdown(how int) error
- func (fd *FD) WSAIoctl(iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *syscall.Overlapped, completionRoutine uintptr) error
- func (fd *FD) Write(buf []byte) (int, error)
- func (fd *FD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (int, int, error)
- func (fd *FD) WriteTo(buf []byte, sa syscall.Sockaddr) (int, error)
- func (fd *FD) Writev(buf *[][]byte) (int64, error)
- type TimeoutError
Variables ¶
var AcceptFunc func(syscall.Handle, syscall.Handle, *byte, uint32, uint32, uint32, *uint32, *syscall.Overlapped) error = syscall.AcceptEx
AcceptFunc is used to hook the accept call.
var CloseFunc func(syscall.Handle) error = syscall.Closesocket
CloseFunc is used to hook the close call.
var ConnectExFunc func(syscall.Handle, syscall.Sockaddr, *byte, uint32, *uint32, *syscall.Overlapped) error = syscall.ConnectEx
ConnectExFunc is used to hook the ConnectEx call.
ErrFileClosing is returned when a file descriptor is used after it has been closed.
ErrNetClosing is returned when a network descriptor is used after it has been closed. Keep this string consistent because of issue #4373: since historically programs have not been able to detect this error, they look for the string.
ErrNoDeadline is returned when a request is made to set a deadline on a file type that does not use the poller.
ErrNotPollable is returned when the file or socket is not suitable for event notification.
var ErrTimeout error = &TimeoutError{}
ErrTimeout is returned for an expired deadline.
var ReadConsole = syscall.ReadConsole // changed for testing
var TestHookDidWritev = func(wrote int) {}
TestHookDidWritev is a hook for testing writev.
Functions ¶
func IsPollDescriptor ¶
IsPollDescriptor reports whether fd is the descriptor being used by the poller. This is only used for testing.
func SendFile ¶
SendFile wraps the TransmitFile call.
Types ¶
type FD ¶
type FD struct { // System file descriptor. Immutable until Close. Sysfd syscall.Handle // Whether this is a streaming descriptor, as opposed to a // packet-based descriptor like a UDP socket. IsStream bool // Whether a zero byte read indicates EOF. This is false for a // message based socket connection. ZeroReadIsEOF bool // contains filtered or unexported fields }
FD is a file descriptor. The net and os packages embed this type in a larger type representing a network connection or OS file.
func (*FD) Accept ¶
func (fd *FD) Accept(sysSocket func() (syscall.Handle, error)) (syscall.Handle, []syscall.RawSockaddrAny, uint32, string, error)
Accept handles accepting a socket. The sysSocket parameter is used to allocate the net socket.
func (*FD) Close ¶
Close closes the FD. The underlying file descriptor is closed by the destroy method when there are no remaining references.
func (*FD) ConnectEx ¶
Call ConnectEx. This doesn't need any locking, since it is only called when the descriptor is first created. This is here rather than in the net package so that it can use fd.wop.
func (*FD) Fchdir ¶
Fchdir wraps syscall.Fchdir.
func (*FD) Fchmod ¶
Fchmod wraps syscall.Fchmod.
func (*FD) Fchown ¶
Fchown wraps syscall.Fchown.
func (*FD) FindNextFile ¶
func (fd *FD) FindNextFile(data *syscall.Win32finddata) error
FindNextFile wraps syscall.FindNextFile.
func (*FD) Fsync ¶
Fsync wraps syscall.Fsync.
func (*FD) Ftruncate ¶
Ftruncate wraps syscall.Ftruncate.
func (*FD) GetFileInformationByHandle ¶
func (fd *FD) GetFileInformationByHandle(data *syscall.ByHandleFileInformation) error
GetFileInformationByHandle wraps GetFileInformationByHandle.
func (*FD) GetFileType ¶
GetFileType wraps syscall.GetFileType.
func (*FD) Init ¶
Init initializes the FD. The Sysfd field should already be set. This can be called multiple times on a single FD. The net argument is a network name from the net package (e.g., "tcp"), or "file" or "console" or "dir". Set pollable to true if fd should be managed by runtime netpoll.
func (*FD) Pread ¶
Pread emulates the Unix pread system call.
func (*FD) Pwrite ¶
Pwrite emulates the Unix pwrite system call.
func (*FD) RawControl ¶
RawControl invokes the user-defined function f for a non-IO operation.
func (*FD) RawRead ¶
RawRead invokes the user-defined function f for a read operation.
func (*FD) RawWrite ¶
RawWrite invokes the user-defined function f for a write operation.
func (*FD) Read ¶
Read implements io.Reader.
func (*FD) ReadFrom ¶
ReadFrom wraps the recvfrom network call.
func (*FD) ReadMsg ¶
ReadMsg wraps the WSARecvMsg network call.
func (*FD) Seek ¶
Seek wraps syscall.Seek.
func (*FD) SetDeadline ¶
SetDeadline sets the read and write deadlines associated with fd.
func (*FD) SetReadDeadline ¶
SetReadDeadline sets the read deadline associated with fd.
func (*FD) SetWriteDeadline ¶
SetWriteDeadline sets the write deadline associated with fd.
func (*FD) Setsockopt ¶
Setsockopt wraps the setsockopt network call.
func (*FD) SetsockoptIPMreq ¶
SetsockoptIPMreq wraps the setsockopt network call with an IPMreq argument.
func (*FD) SetsockoptIPv6Mreq ¶
SetsockoptIPv6Mreq wraps the setsockopt network call with an IPv6Mreq argument.
func (*FD) SetsockoptInet4Addr ¶
SetsockoptInet4Addr wraps the setsockopt network call with an IPv4 address.
func (*FD) SetsockoptInt ¶
SetsockoptInt wraps the setsockopt network call with an int argument.
func (*FD) SetsockoptLinger ¶
SetsockoptLinger wraps the setsockopt network call with a Linger argument.
func (*FD) Shutdown ¶
Shutdown wraps the shutdown network call.
func (*FD) WSAIoctl ¶
func (fd *FD) WSAIoctl(iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *syscall.Overlapped, completionRoutine uintptr) error
WSAIoctl wraps the WSAIoctl network call.
func (*FD) Write ¶
Write implements io.Writer.
func (*FD) WriteMsg ¶
WriteMsg wraps the WSASendMsg network call.
func (*FD) WriteTo ¶
WriteTo wraps the sendto network call.
func (*FD) Writev ¶
Writev emulates the Unix writev system call.
type TimeoutError ¶
type TimeoutError struct{}
TimeoutError is returned for an expired deadline.
func (*TimeoutError) Error ¶
func (e *TimeoutError) Error() string
Implement the net.Error interface.
func (*TimeoutError) Temporary ¶
func (e *TimeoutError) Temporary() bool
func (*TimeoutError) Timeout ¶
func (e *TimeoutError) Timeout() bool
Source Files ¶
errno_windows.go fd.go fd_fsync_windows.go fd_mutex.go fd_poll_runtime.go fd_posix.go fd_windows.go hook_windows.go sendfile_windows.go sockopt.go sockopt_windows.go sockoptip.go
- Version
- v1.14.2
- Published
- Apr 8, 2020
- Platform
- windows/amd64
- Imports
- 12 packages
- Last checked
- 12 minutes ago –
Tools for package owners.