mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 17:38:41 +00:00
v1.0.0
This commit is contained in:
parent
47d23e9972
commit
c7f7c08ead
711 changed files with 82154 additions and 2 deletions
39
common/buf/readv_windows.go
Normal file
39
common/buf/readv_windows.go
Normal file
|
@ -0,0 +1,39 @@
|
|||
package buf
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
type windowsReader struct {
|
||||
bufs []syscall.WSABuf
|
||||
}
|
||||
|
||||
func (r *windowsReader) Init(bs []*Buffer) {
|
||||
if r.bufs == nil {
|
||||
r.bufs = make([]syscall.WSABuf, 0, len(bs))
|
||||
}
|
||||
for _, b := range bs {
|
||||
r.bufs = append(r.bufs, syscall.WSABuf{Len: uint32(Size), Buf: &b.v[0]})
|
||||
}
|
||||
}
|
||||
|
||||
func (r *windowsReader) Clear() {
|
||||
for idx := range r.bufs {
|
||||
r.bufs[idx].Buf = nil
|
||||
}
|
||||
r.bufs = r.bufs[:0]
|
||||
}
|
||||
|
||||
func (r *windowsReader) Read(fd uintptr) int32 {
|
||||
var nBytes uint32
|
||||
var flags uint32
|
||||
err := syscall.WSARecv(syscall.Handle(fd), &r.bufs[0], uint32(len(r.bufs)), &nBytes, &flags, nil, nil)
|
||||
if err != nil {
|
||||
return -1
|
||||
}
|
||||
return int32(nBytes)
|
||||
}
|
||||
|
||||
func newMultiReader() multiReader {
|
||||
return new(windowsReader)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue