当前位置: 首页>>代码示例>>Golang>>正文


Golang syscall.WSASendto函数代码示例

本文整理汇总了Golang中syscall.WSASendto函数的典型用法代码示例。如果您正苦于以下问题:Golang WSASendto函数的具体用法?Golang WSASendto怎么用?Golang WSASendto使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了WSASendto函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: timeoutIO

func timeoutIO() {
	// CancelIO only cancels all pending input and output (I/O) operations that are
	// issued by the calling thread for the specified file, does not cancel I/O
	// operations that other threads issue for a file handle. So we need do all timeout
	// I/O in single OS thread.
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()
	for {
		o := <-ioChan
		var e int
		switch o.f {
		case read:
			e = syscall.WSARecv(uint32(o.fd.sysfd), o.pckt.w, 1, o.done, o.flags, &o.pckt.o, nil)
		case readfrom:
			e = syscall.WSARecvFrom(uint32(o.fd.sysfd), o.pckt.w, 1, o.done, o.flags, o.rsa, o.size, &o.pckt.o, nil)
		case write:
			e = syscall.WSASend(uint32(o.fd.sysfd), o.pckt.w, 1, o.done, uint32(0), &o.pckt.o, nil)
		case writeto:
			e = syscall.WSASendto(uint32(o.fd.sysfd), o.pckt.w, 1, o.done, 0, *o.sa, &o.pckt.o, nil)
		case cancel:
			_, e = syscall.CancelIo(uint32(o.fd.sysfd))
		}
		o.c <- e
	}
}
开发者ID:IntegerCompany,项目名称:linaro-android-gcc,代码行数:25,代码来源:fd_windows.go

示例2: Write

func (c *Conn) Write(b []byte) error {
	buf := &s.WSABuf{
		Len: uint32(len(b)),
		Buf: &b[0],
	}
	var sent *uint32
	c.overlapped = s.Overlapped{}
	croutine := byte(0)
	fmt.Printf("\nEnvoi en cours\n")
	err := s.WSASendto(c.sd, buf, 1, sent, uint32(0), &c.sa, &c.overlapped, &croutine)
	return err
}
开发者ID:adrien3d,项目名称:gobox,代码行数:12,代码来源:connection_windows.go

示例3: write

func (s *Ssdp) write(msg writeMessage) error {
	bufs := syscall.WSABuf{
		Len: uint32(len(msg.message)),
		Buf: &msg.message[0],
	}
	as4 := msg.to.IP.To4()
	to := &syscall.SockaddrInet4{
		Port: msg.to.Port,
		Addr: [4]byte{as4[0], as4[1], as4[2], as4[3]},
	}
	msgLen := uint32(len(msg.message))
	err := syscall.WSASendto(s.socket.socket, &bufs, 1, &msgLen, 0, to, nil, nil)
	return err
}
开发者ID:mark2b,项目名称:gossdp,代码行数:14,代码来源:broadcast_windows.go

示例4: WriteTo

func (fd *netFD) WriteTo(buf []byte, sa syscall.Sockaddr) (int, error) {
	if len(buf) == 0 {
		return 0, nil
	}
	if err := fd.writeLock(); err != nil {
		return 0, err
	}
	defer fd.writeUnlock()
	o := &fd.wop
	o.InitBuf(buf)
	o.sa = sa
	return wsrv.ExecIO(o, "WSASendto", func(o *operation) error {
		return syscall.WSASendto(o.fd.sysfd, &o.buf, 1, &o.qty, 0, o.sa, &o.o, nil)
	})
}
开发者ID:maqayum,项目名称:gcc-libitm,代码行数:15,代码来源:fd_windows.go

示例5: WriteTo

func (fd *netFD) WriteTo(p []byte, sa syscall.Sockaddr) (n int, err os.Error) {
	if fd == nil {
		return 0, os.EINVAL
	}
	if len(p) == 0 {
		return 0, nil
	}
	fd.wio.Lock()
	defer fd.wio.Unlock()
	fd.incref()
	defer fd.decref()
	if fd.sysfd == -1 {
		return 0, os.EINVAL
	}
	// Submit send request.
	var pckt ioPacket
	pckt.c = fd.cw
	pckt.w = newWSABuf(p)
	var done uint32
	var e int
	if fd.wdeadline_delta > 0 {
		a := &arg{f: writeto, fd: fd, pckt: &pckt, done: &done, sa: &sa, c: make(chan int)}
		ioChan <- a
		e = <-a.c
	} else {
		e = syscall.WSASendto(uint32(fd.sysfd), pckt.w, 1, &done, 0, sa, &pckt.o, nil)
	}
	switch e {
	case 0:
		// IO completed immediately, but we need to get our completion message anyway.
	case syscall.ERROR_IO_PENDING:
		// IO started, and we have to wait for it's completion.
	default:
		return 0, &OpError{"WSASendTo", fd.net, fd.laddr, os.Errno(e)}
	}
	// Wait for our request to complete.
	r := waitPacket(fd, &pckt, 'w')
	if r.errno != 0 {
		err = &OpError{"WSASendTo", fd.net, fd.laddr, os.Errno(r.errno)}
	}
	n = int(r.qty)
	return
}
开发者ID:IntegerCompany,项目名称:linaro-android-gcc,代码行数:43,代码来源:fd_windows.go

示例6: writeTo

func (fd *netFD) writeTo(buf []byte, sa syscall.Sockaddr) (int, error) {
	if len(buf) == 0 {
		return 0, nil
	}
	if err := fd.writeLock(); err != nil {
		return 0, err
	}
	defer fd.writeUnlock()
	o := &fd.wop
	o.InitBuf(buf)
	o.sa = sa
	n, err := wsrv.ExecIO(o, "WSASendto", func(o *operation) error {
		return syscall.WSASendto(o.fd.sysfd, &o.buf, 1, &o.qty, 0, o.sa, &o.o, nil)
	})
	if _, ok := err.(syscall.Errno); ok {
		err = os.NewSyscallError("wsasendto", err)
	}
	return n, err
}
开发者ID:gmwu,项目名称:go,代码行数:19,代码来源:fd_windows.go

示例7: Submit

func (o *writeToOp) Submit() error {
	var d uint32
	return syscall.WSASendto(o.fd.sysfd, &o.buf, 1, &d, 0, o.sa, &o.o, nil)
}
开发者ID:serge-hulne,项目名称:golang,代码行数:4,代码来源:fd_windows.go

示例8: Submit

func (o *writeToOp) Submit() (errno int) {
	var d uint32
	return syscall.WSASendto(uint32(o.fd.sysfd), &o.buf, 1, &d, 0, o.sa, &o.o, nil)
}
开发者ID:jnwhiteh,项目名称:go,代码行数:4,代码来源:fd_windows.go


注:本文中的syscall.WSASendto函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。