github.com/flyinox/gosm@v0.0.0-20171117061539-16768cb62077/src/internal/poll/sendfile_windows.go (about) 1 // Copyright 2011 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 package poll 6 7 import "syscall" 8 9 // SendFile wraps the TransmitFile call. 10 func SendFile(fd *FD, src syscall.Handle, n int64) (int64, error) { 11 if err := fd.writeLock(); err != nil { 12 return 0, err 13 } 14 defer fd.writeUnlock() 15 16 o := &fd.wop 17 o.qty = uint32(n) 18 o.handle = src 19 done, err := wsrv.ExecIO(o, func(o *operation) error { 20 return syscall.TransmitFile(o.fd.Sysfd, o.handle, o.qty, 0, &o.o, nil, syscall.TF_WRITE_BEHIND) 21 }) 22 return int64(done), err 23 }