The original request was for "os/poll", I think that would be best, or "runtime/poll". Agreed that "net" makes no sense, because it actually has nothing inherently to do with networking. I would imagine an API something like this.
type Descriptor struct {
// contains filtered or unexported fields
}const (
Read = 0
Write = 1
)
func Open(fd int) (*Descriptor, error)
func (d *Descriptor) Close() error// Design Question: Should Open/Close be used, or Register/DeRegister (the file descriptor would already be allocated, and would not actually be closed with Close), however Open/Close seem to be the standard way of doing it.
func (d *Descriptor) Read(p []byte) (n int, err error)
func (d *Descriptor) Write(b []byte) (n int, err error)
func (d *Descriptor) SetDeadline(t time.Time) error
func (d *Descriptor) SetReadDeadline(t time.Time) error
func (d *Descriptor) SetWriteDeadline(t time.Time) error// QUESTION: Should LocalAddr() and RemoteAddr() be added for net.Conn compatibility?
func (d *Descriptor) Wait(mode int) error// mode => poll.Read, poll.Write, or poll.Read | poll.Write
func (d *Descriptor) Cancel() error// concurrently cancel a blocking Read, Write, or Wait call.
From my list, this directly addresses the first 4 links, as they are all more or less are directly asking for this package.
Issues
10565,
15021, would be addressed indirectly, creating a net.Conn or net.PacketConn by wrapping a Descriptor would be trivial.
Similarily, this would solve my problem with creating a net.Conn from the SocketCAN type that was to x/sys/unix in issue
16188.