本文整理匯總了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
}
示例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
}
示例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
}
示例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
}
示例5: Send
func Send(socket ZSocket, message ZMessage, flags int) os.Error {
return handle(C.zmq_send(socket.Ptr, message.Ptr, C.int(flags)))
}