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


Golang C.zmq_socket函数代码示例

本文整理汇总了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
}
开发者ID:badgerodon,项目名称:zmq,代码行数:7,代码来源:zmq.go

示例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()
}
开发者ID:psilva261,项目名称:gozmq,代码行数:9,代码来源:zmq.go

示例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
}
开发者ID:miffa,项目名称:gozero,代码行数:11,代码来源:zmq.go

示例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)
}
开发者ID:brunoqc,项目名称:gozmq,代码行数:10,代码来源:zmq.go

示例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
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:20,代码来源:zmq3.go

示例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
}
开发者ID:pakohan,项目名称:go-zmq,代码行数:13,代码来源:zmq.go

示例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
}
开发者ID:lucmichalski,项目名称:goiostat,代码行数:23,代码来源:zmq3.go


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