當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。