// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build unix || windows

package net

import (
	
	
	
	
)

// Network file descriptor.
type netFD struct {
	pfd poll.FD

	// immutable until Close
	family      int
	sotype      int
	isConnected bool // handshake completed or use of association with peer
	net         string
	laddr       Addr
	raddr       Addr
}

func ( *netFD) (,  Addr) {
	.laddr = 
	.raddr = 
	runtime.SetFinalizer(, (*netFD).Close)
}

func ( *netFD) () error {
	runtime.SetFinalizer(, nil)
	return .pfd.Close()
}

func ( *netFD) ( int) error {
	 := .pfd.Shutdown()
	runtime.KeepAlive()
	return wrapSyscallError("shutdown", )
}

func ( *netFD) () error {
	return .shutdown(syscall.SHUT_RD)
}

func ( *netFD) () error {
	return .shutdown(syscall.SHUT_WR)
}

func ( *netFD) ( []byte) ( int,  error) {
	,  = .pfd.Read()
	runtime.KeepAlive()
	return , wrapSyscallError(readSyscallName, )
}

func ( *netFD) ( []byte) ( int,  syscall.Sockaddr,  error) {
	, ,  = .pfd.ReadFrom()
	runtime.KeepAlive()
	return , , wrapSyscallError(readFromSyscallName, )
}
func ( *netFD) ( []byte,  *syscall.SockaddrInet4) ( int,  error) {
	,  = .pfd.ReadFromInet4(, )
	runtime.KeepAlive()
	return , wrapSyscallError(readFromSyscallName, )
}

func ( *netFD) ( []byte,  *syscall.SockaddrInet6) ( int,  error) {
	,  = .pfd.ReadFromInet6(, )
	runtime.KeepAlive()
	return , wrapSyscallError(readFromSyscallName, )
}

func ( *netFD) ( []byte,  []byte,  int) (, ,  int,  syscall.Sockaddr,  error) {
	, , , ,  = .pfd.ReadMsg(, , )
	runtime.KeepAlive()
	return , , , , wrapSyscallError(readMsgSyscallName, )
}

func ( *netFD) ( []byte,  []byte,  int,  *syscall.SockaddrInet4) (, ,  int,  error) {
	, , ,  = .pfd.ReadMsgInet4(, , , )
	runtime.KeepAlive()
	return , , , wrapSyscallError(readMsgSyscallName, )
}

func ( *netFD) ( []byte,  []byte,  int,  *syscall.SockaddrInet6) (, ,  int,  error) {
	, , ,  = .pfd.ReadMsgInet6(, , , )
	runtime.KeepAlive()
	return , , , wrapSyscallError(readMsgSyscallName, )
}

func ( *netFD) ( []byte) ( int,  error) {
	,  = .pfd.Write()
	runtime.KeepAlive()
	return , wrapSyscallError(writeSyscallName, )
}

func ( *netFD) ( []byte,  syscall.Sockaddr) ( int,  error) {
	,  = .pfd.WriteTo(, )
	runtime.KeepAlive()
	return , wrapSyscallError(writeToSyscallName, )
}

func ( *netFD) ( []byte,  *syscall.SockaddrInet4) ( int,  error) {
	,  = .pfd.WriteToInet4(, )
	runtime.KeepAlive()
	return , wrapSyscallError(writeToSyscallName, )
}

func ( *netFD) ( []byte,  *syscall.SockaddrInet6) ( int,  error) {
	,  = .pfd.WriteToInet6(, )
	runtime.KeepAlive()
	return , wrapSyscallError(writeToSyscallName, )
}

func ( *netFD) ( []byte,  []byte,  syscall.Sockaddr) ( int,  int,  error) {
	, ,  = .pfd.WriteMsg(, , )
	runtime.KeepAlive()
	return , , wrapSyscallError(writeMsgSyscallName, )
}

func ( *netFD) ( []byte,  []byte,  *syscall.SockaddrInet4) ( int,  int,  error) {
	, ,  = .pfd.WriteMsgInet4(, , )
	runtime.KeepAlive()
	return , , wrapSyscallError(writeMsgSyscallName, )
}

func ( *netFD) ( []byte,  []byte,  *syscall.SockaddrInet6) ( int,  int,  error) {
	, ,  = .pfd.WriteMsgInet6(, , )
	runtime.KeepAlive()
	return , , wrapSyscallError(writeMsgSyscallName, )
}

func ( *netFD) ( time.Time) error {
	return .pfd.SetDeadline()
}

func ( *netFD) ( time.Time) error {
	return .pfd.SetReadDeadline()
}

func ( *netFD) ( time.Time) error {
	return .pfd.SetWriteDeadline()
}