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