本文整理汇总了Golang中C.zmq_socket函数的典型用法代码示例。如果您正苦于以下问题:Golang zmq_socket函数的具体用法?Golang zmq_socket怎么用?Golang zmq_socket使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zmq_socket函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Socket
func Socket(context ZContext, socketType int) (ZSocket, os.Error) {
ptr := C.zmq_socket(context.Ptr, C.int(socketType))
if ptr == nil {
return ZSocket{nil}, error()
}
return ZSocket{ptr}, nil
}
示例2: NewSocket
// Create a new socket.
// void *zmq_socket (void *context, int type);
func (c *zmqContext) NewSocket(t SocketType) (Socket, error) {
// C.NULL is correct but causes a runtime failure on darwin at present
if s := C.zmq_socket(c.c, C.int(t)); s != nil /*C.NULL*/ {
return &zmqSocket{c: c, s: s}, nil
}
return nil, errno()
}
示例3: NewSocket
// Creates a new Socket with the given socketType
//
// Sockets only must be used from a fixed OSThread. This may be achieved
// by conveniently using Thunk.NewOSThread() or by calling runtime.LockOSThread()
func (p lzmqContext) NewSocket(socketType int) (Socket, os.Error) {
ptr := unsafe.Pointer(C.zmq_socket(unsafe.Pointer(p), C.int(socketType)))
if IsCNullPtr(uintptr(ptr)) {
return nil, p.Provider().GetError()
}
return lzmqSocket(ptr), nil
}
示例4: NewSocket
// Create a new socket.
// void *zmq_socket (void *context, int type);
func (c *Context) NewSocket(t SocketType) (*Socket, error) {
s, err := C.zmq_socket(c.c, C.int(t))
// C.NULL is correct but causes a runtime failure on darwin at present
if s != nil /*C.NULL*/ {
return &Socket{c: c, s: s}, nil
}
return nil, casterr(err)
}
示例5: NewSocket
/*
Create 0MQ socket.
WARNING:
The Socket is not thread safe. This means that you cannot access the same Socket
from different goroutines without using something like a mutex.
For a description of socket types, see: http://api.zeromq.org/3-2:zmq-socket#toc3
*/
func NewSocket(t Type) (soc *Socket, err error) {
soc = &Socket{}
s, e := C.zmq_socket(ctx, C.int(t))
if s == nil {
err = errget(e)
} else {
soc.soc = s
runtime.SetFinalizer(soc, (*Socket).Close)
}
return
}
示例6: Socket
// Creates a new Socket of the specified type.
func (c *Context) Socket(socktype SocketType) (sock *Socket, err error) {
ptr := C.zmq_socket(c.ctx, C.int(socktype))
if ptr == nil {
return nil, zmqerr()
}
sock = &Socket{
ctx: c,
sock: ptr,
}
sock.SetLinger(0)
return
}
示例7: NewSocket
/*
Create 0MQ socket in the given context.
WARNING:
The Socket is not thread safe. This means that you cannot access the same Socket
from different goroutines without using something like a mutex.
For a description of socket types, see: http://api.zeromq.org/3-2:zmq-socket#toc3
*/
func (ctx *Context) NewSocket(t Type) (soc *Socket, err error) {
soc = &Socket{}
s, e := C.zmq_socket(ctx.ctx, C.int(t))
if s == nil {
err = errget(e)
soc.err = err
} else {
soc.soc = s
soc.ctx = ctx
soc.opened = true
runtime.SetFinalizer(soc, (*Socket).Close)
}
return
}