本文整理汇总了Python中pyczmq._cffi.C类的典型用法代码示例。如果您正苦于以下问题:Python C类的具体用法?Python C怎么用?Python C使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了C类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: apply
def apply(cert, zocket):
"""
Apply certificate to socket, i.e. use for CURVE security on socket.
If certificate was loaded from public file, the secret key will be
undefined, and this certificate will not work successfully.
"""
C.zcert_apply(cert, zocket)
示例2: send
def send(m, socket):
"""
Send message to socket, destroy after sending. If the message has no
frames, sends nothing but destroys the message anyhow. Safe to call
if zmsg is null.
"""
C.zmsg_send(ptop('zmsg_t', m), socket)
示例3: destroy
def destroy(loop):
"""
Destroy a reactor, this is not necessary if you create it with
new.
"""
if loop is not ffi.NULL:
C.zloop_destroy(ptop('zloop_t', loop))
return ffi.NULL
示例4: append
def append(m, f):
"""
Add frame to the end of the message, i.e. after all other frames.
Message takes ownership of frame, will destroy it when message is sent.
Returns 0 on success. Deprecates zmsg_add, which did not nullify the
caller's frame reference.
"""
C.zmsg_append(m, ptop('zframe_t', f))
示例5: destroy
def destroy(ctx, socket):
"""Destroy a socket within our CZMQ context.
'pyczmq.zsocket.new' automatically registers this destructor with
the garbage collector, so this is normally not necessary to use,
unless you need to destroy sockets created by some other means
(like a call directly to 'pyczmq.C.zsocket_new')
"""
C.zsocket_destroy(ctx, socket)
示例6: zsys_version
def zsys_version():
"""
Returns the tuple (major, minor, patch) of the current czmq version.
"""
major = ffi.new('int*')
minor= ffi.new('int*')
patch = ffi.new('int*')
C.zsys_version(major, minor, patch)
return (major[0], minor[0], patch[0])
示例7: insert
def insert(store, cert):
"""
Insert certificate into certificate store in memory. Note that this
does not save the certificate to disk. To do that, use zcert_save()
directly on the certificate. Takes ownership of zcert_t object.
"""
return C.zcertstore_insert(store, ptop('zcert_t', cert))
示例8: sendx
def sendx(sock, *strings):
"""
Send a series of strings (until NULL) as multipart data
Returns 0 if the strings could be sent OK, or -1 on error.
"""
varargs = [ffi.new('char[]', s) for s in strings] + [ffi.NULL]
return C.zstr_sendx(sock, *varargs)
示例9: new_empty
def new_empty():
"""Create an empty (zero-sized) frame.
Note, no gc wrapper, frames self-destruct by send. If you don't
send a frame, you DO have to destroy() it.
"""
return C.zframe_new_empty()
示例10: new
def new(data):
"""Create a new frame with optional size, and optional data
Note, no gc wrapper, frames self-destruct by send. If you don't
send a frame, you DO have to destroy() it.
"""
return C.zframe_new(data, len(data))
示例11: signal
def signal(sock, status):
"""Send a signal over a socket. A signal is a short message carrying a
success/failure code (by convention, 0 means OK). Signals are encoded
to be distinguishable from "normal" messages. Accepts a zock_t or a
zactor_t argument, and returns 0 if successful, -1 if the signal could
not be sent."""
return C.zsock_signal(sock, status)
示例12: load
def load(msg, filename):
"""
Load/append an open file into message, create new message if
null message provided. Returns NULL if the message could not
be loaded.
"""
return C.zmsg_load(msg, filename)
示例13: poller_end
def poller_end(loop, item):
"""
Cancel a pollitem from the reactor, specified by socket or FD. If both
are specified, uses only socket. If multiple poll items exist for same
socket/FD, cancels ALL of them.
"""
return C.zloop_poller_end(loop, item)
示例14: recv
def recv(socket):
"""
Receive message from socket, returns zmsg_t object or NULL if the recv
was interrupted. Does a blocking recv, if you want to not block then use
the zloop class or zmq_poll to check for socket input before receiving.
"""
return C.zmsg_recv(socket)
示例15: push
def push(msg, frame):
"""
Push frame to the front of the message, i.e. before all other frames.
Message takes ownership of frame, will destroy it when message is sent.
Returns 0 on success, -1 on error.
"""
return C.zmsg_push(msg, frame)