devices.py revision 781d71db
1# coding: utf-8
2"""zmq device functions"""
3
4# Copyright (C) PyZMQ Developers
5# Distributed under the terms of the Modified BSD License.
6
7from ._cffi import C, ffi, zmq_version_info
8from .socket import Socket
9from zmq.error import ZMQError, _check_rc
10
11def device(device_type, frontend, backend):
12    rc = C.zmq_proxy(frontend._zmq_socket, backend._zmq_socket, ffi.NULL)
13    _check_rc(rc)
14
15def proxy(frontend, backend, capture=None):
16    if isinstance(capture, Socket):
17        capture = capture._zmq_socket
18    else:
19        capture = ffi.NULL
20
21    rc = C.zmq_proxy(frontend._zmq_socket, backend._zmq_socket, capture)
22    _check_rc(rc)
23
24__all__ = ['device', 'proxy']
25