...

Source file src/os/rawconn.go

Documentation: os

		 1  // Copyright 2018 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.
		 4  
		 5  //go:build !plan9
		 6  // +build !plan9
		 7  
		 8  package os
		 9  
		10  import (
		11  	"runtime"
		12  )
		13  
		14  // rawConn implements syscall.RawConn.
		15  type rawConn struct {
		16  	file *File
		17  }
		18  
		19  func (c *rawConn) Control(f func(uintptr)) error {
		20  	if err := c.file.checkValid("SyscallConn.Control"); err != nil {
		21  		return err
		22  	}
		23  	err := c.file.pfd.RawControl(f)
		24  	runtime.KeepAlive(c.file)
		25  	return err
		26  }
		27  
		28  func (c *rawConn) Read(f func(uintptr) bool) error {
		29  	if err := c.file.checkValid("SyscallConn.Read"); err != nil {
		30  		return err
		31  	}
		32  	err := c.file.pfd.RawRead(f)
		33  	runtime.KeepAlive(c.file)
		34  	return err
		35  }
		36  
		37  func (c *rawConn) Write(f func(uintptr) bool) error {
		38  	if err := c.file.checkValid("SyscallConn.Write"); err != nil {
		39  		return err
		40  	}
		41  	err := c.file.pfd.RawWrite(f)
		42  	runtime.KeepAlive(c.file)
		43  	return err
		44  }
		45  
		46  func newRawConn(file *File) (*rawConn, error) {
		47  	return &rawConn{file: file}, nil
		48  }
		49  

View as plain text