當前位置: 首頁>>代碼示例>>Golang>>正文


Golang C.zmq_send函數代碼示例

本文整理匯總了Golang中C.zmq_send函數的典型用法代碼示例。如果您正苦於以下問題:Golang zmq_send函數的具體用法?Golang zmq_send怎麽用?Golang zmq_send使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了zmq_send函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: SendBytes

/*
Send a message part on a socket.

For a description of flags, see: http://api.zeromq.org/3-2:zmq-send#toc2
*/
func (soc *Socket) SendBytes(data []byte, flags Flag) (int, error) {
	d := data
	if len(data) == 0 {
		d = []byte{0}
	}
	size, err := C.zmq_send(soc.soc, unsafe.Pointer(&d[0]), C.size_t(len(data)), C.int(flags))
	if size < 0 {
		return int(size), errget(err)
	}
	return int(size), nil
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:16,代碼來源:zmq3.go

示例2: SendBytes

/*
Send a message part on a socket.

For a description of flags, see: http://api.zeromq.org/2-2:zmq-send#toc2
*/
func (soc *Socket) SendBytes(data []byte, flags Flag) (int, error) {
	datac := C.CString(string(data))
	var msg C.zmq_msg_t
	if i, err := C.my_msg_init_data(&msg, unsafe.Pointer(datac), C.size_t(len(data))); i != 0 {
		return -1, errget(err)
	}
	defer C.zmq_msg_close(&msg)
	n, err := C.zmq_send(soc.soc, &msg, C.int(flags))
	if n != 0 {
		return -1, errget(err)
	}
	return int(n), nil
}
開發者ID:patrickToca,項目名稱:zmq2,代碼行數:18,代碼來源:zmq2.go

示例3: Send

func (p lzmqSocket) Send(msg Message, flags int) os.Error {
	if msg == nil {
		return os.EINVAL
	}
	lzmqMsgHolder, err := msg.(lzmqMessageHolder)
	if err == false {
		return os.EINVAL
	}
	lzmqMsg := lzmqMsgHolder.getLzmqMessage()
	ret := p.Provider().OkIf(C.zmq_send(unsafe.Pointer(p), lzmqMsg.ptr(), C.int(flags)) == 0)
	// fmt.Println("sent", msg)
	return ret
}
開發者ID:miffa,項目名稱:gozero,代碼行數:13,代碼來源:zmq.go

示例4: Send

// Send a message to the socket.
// int zmq_send (void *s, zmq_msg_t *msg, int flags);
func (s *zmqSocket) Send(data []byte, flags SendRecvOption) error {
	var m C.zmq_msg_t
	// Copy data array into C-allocated buffer.
	size := C.size_t(len(data))

	if C.zmq_msg_init_size(&m, size) != 0 {
		return errno()
	}

	if size > 0 {
		// FIXME Ideally this wouldn't require a copy.
		C.memcpy(unsafe.Pointer(C.zmq_msg_data(&m)), unsafe.Pointer(&data[0]), size) // XXX I hope this works...(seems to)
	}

	if C.zmq_send(s.s, &m, C.int(flags)) != 0 {
		// zmq_send did not take ownership, free message
		C.zmq_msg_close(&m)
		return errno()
	}
	return nil
}
開發者ID:ajanicij,項目名稱:gozmq,代碼行數:23,代碼來源:zmq_2_x.go

示例5: Send

func Send(socket ZSocket, message ZMessage, flags int) os.Error {
	return handle(C.zmq_send(socket.Ptr, message.Ptr, C.int(flags)))
}
開發者ID:badgerodon,項目名稱:zmq,代碼行數:3,代碼來源:zmq.go


注:本文中的C.zmq_send函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。