github.com/megatontech/mynoteforgo@v0.0.0-20200507084910-5d0c6ea6e890/源码/net/writev_unix.go (about)

     1  // Copyright 2016 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  // +build darwin dragonfly freebsd linux netbsd openbsd
     6  
     7  package net
     8  
     9  import (
    10  	"runtime"
    11  	"syscall"
    12  )
    13  
    14  func (c *conn) writeBuffers(v *Buffers) (int64, error) {
    15  	if !c.ok() {
    16  		return 0, syscall.EINVAL
    17  	}
    18  	n, err := c.fd.writeBuffers(v)
    19  	if err != nil {
    20  		return n, &OpError{Op: "writev", Net: c.fd.net, Source: c.fd.laddr, Addr: c.fd.raddr, Err: err}
    21  	}
    22  	return n, nil
    23  }
    24  
    25  func (fd *netFD) writeBuffers(v *Buffers) (n int64, err error) {
    26  	n, err = fd.pfd.Writev((*[][]byte)(v))
    27  	runtime.KeepAlive(fd)
    28  	return n, wrapSyscallError("writev", err)
    29  }