本文整理匯總了Golang中syscall.Iovec.Base方法的典型用法代碼示例。如果您正苦於以下問題:Golang Iovec.Base方法的具體用法?Golang Iovec.Base怎麽用?Golang Iovec.Base使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類syscall.Iovec
的用法示例。
在下文中一共展示了Iovec.Base方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: sendMMsg
func sendMMsg(addr *net.UDPAddr, i int) {
i = i / chunk_sz
log.Printf("Start `sendMMsg` test with %d iteration\n", i)
laddr := UDPAddrToSockaddr(&net.UDPAddr{Port: local_port, IP: net.IPv4zero})
raddr := UDPAddrToSockaddr(addr)
fd := connectUDP(laddr, raddr)
msgcnt := chunk_sz
var msgArr [chunk_sz]MMsghdr
for j := 0; j < msgcnt; j++ {
p := make([]byte, payload_sz)
for k := 0; k < payload_sz; k++ {
p[k] = byte(k)
}
var iov syscall.Iovec
iov.Base = (*byte)(unsafe.Pointer(&p[0]))
iov.SetLen(len(p))
var msg syscall.Msghdr
msg.Iov = &iov
msg.Iovlen = 1
msgArr[j] = MMsghdr{msg, 0}
}
for ; i > 0; i-- {
//_, _, e1 := syscall.Syscall6(C.SYS_sendmmsg, uintptr(fd), uintptr(unsafe.Pointer(&msgArr[0])), uintptr(msgcnt), uintptr(syscall.MSG_DONTWAIT), 0, 0)
_, _, e1 := syscall.Syscall6(C.SYS_sendmmsg, uintptr(fd), uintptr(unsafe.Pointer(&msgArr[0])), uintptr(msgcnt), 0, 0, 0)
if e1 != 0 {
panic("error on sendmmsg")
}
}
}