
    Mh                    (   U d Z ddlmZ 	 ddlZej        s
 e            n9# e$ r1 ddlmZ  ee          j	        d         Z
de
 de
 dZ ee          w xY wddlZdd	lmZ dd
lmZ ddlmZ ddlZddlmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z# ddl$m%Z%m&Z&m'Z'm(Z(m)Z) ddl*m+Z+m,Z,m-Z- ddl.m/Z/ ddl0m1Z1m2Z2m3Z3m4Z4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl8m:Z; ddl<m=Z=m>Z> ddl?m@Z@ ddlAmBZBmCZCmDZDmEZEmFZFmGZG ddlHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~mZmZmZmZmZmZmZmZ ddlHmZ ddlHmZ ddlZddlmZmZ ddlmZmZmZmZmZ  eB            Zded<   ee ej        d          dsdtd%                                    Z ej        e  e!eF          e"&          Zeedud*                        Zeedvd.                        Zeedsdwd3                        Zdae G d4 d5                      Ze G d6 d7                      Zeedxd9                        Ze G d: d;                      Zeedyd=                        Zeedzd>                        Zeed{d|dB                        Zeed}d~dC                        Zeed}ddE                        Zeed}d~dF                        ZeeddK                        ZeeddL                        ZddMZddPZddRZddUZddWZddXZdddZZddd^Z	 	 ddd`Zeeeddh                                    Zeeeddk                                    Z	 	 dddqZg drZdS )zCython backend for pyzmq    )annotationsN)Path   z
    Attempting to import zmq Cython backend, which has not been compiled.

    This probably means you are importing zmq from its source tree.
    if this is what you want, make sure to do an in-place build first:

        pip install -e 'z'

    If it is not, then 'a!  ' is probably on your sys.path,
    when it shouldn't be. Is that your current working directory?

    If neither of those is true and this file is actually installed,
    something seems to have gone wrong with the install!
    Please report at https://github.com/zeromq/pyzmq/issues
    )Event)	monotonic)ref)NULL
Py_ssize_taddressbintcastcclasscfuncchardeclareinlinenogilp_charp_voidpointersize_tsizeof)	Py_bufferPyBUF_ANY_CONTIGUOUSPyBUF_WRITABLEPyBuffer_ReleasePyObject_GetBuffer)PyBytes_AsStringPyBytes_FromStringAndSizePyBytes_Size)PyErr_CheckSignals)EAGAINEINTRENAMETOOLONGENOENTENOTSOCK)uint32_t)fprintf)stderr)freemalloc)memcpy)get_ipc_path_max_lengetpidmutex_allocate
mutex_lockmutex_tmutex_unlock)>ZMQ_ENOTSOCK	ZMQ_ETERMZMQ_EVENT_ALLZMQ_FDZMQ_IDENTITYZMQ_IO_THREADS
ZMQ_LINGER
ZMQ_POLLINZMQ_POLLOUTZMQ_RCVMORE
ZMQ_ROUTERZMQ_SNDMOREZMQ_THREAD_SAFEZMQ_TYPE_zmq_versionfd_tint64_tzmq_bind	zmq_closezmq_connectzmq_ctx_destroyzmq_ctx_getzmq_ctx_newzmq_ctx_setzmq_curve_keypairzmq_curve_publiczmq_disconnectzmq_free_fnzmq_getsockoptzmq_haszmq_join	zmq_leavezmq_msg_closezmq_msg_copyzmq_msg_datazmq_msg_getzmq_msg_getszmq_msg_groupzmq_msg_initzmq_msg_init_datazmq_msg_init_sizezmq_msg_recvzmq_msg_routing_idzmq_msg_sendzmq_msg_setzmq_msg_set_groupzmq_msg_set_routing_idzmq_msg_size	zmq_msg_tzmq_poller_addzmq_poller_destroyzmq_poller_fdzmq_poller_newzmq_pollitem_t	zmq_proxyzmq_proxy_steerablezmq_recvzmq_setsockopt
zmq_socketzmq_socket_monitorzmq_strerror
zmq_unbind)	zmq_errno)zmq_poll)SocketOption_OptType)AgainContextTerminatedInterruptedSystemCallZMQError_check_versionintIPC_PATH_MAX_LENFrcC.interror_without_errnor   returnc                   t                      }t                       |dk    r|sdS | dk    r]|t          k    rt          |          |t          k    rt          |          |t          k    rt          |          t          |          dS )zhinternal utility for checking zmq return condition

    and raising the appropriate Exception class
    r   r|   )	
_zmq_errnor!   r#   rw   r"   ru   r4   rv   rx   )r}   r   errnos      W/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/zmq/backend/cython/_zmq.py	_check_rcr      s     <<Ezz-zq	RxxE>>'...f__,,i#E***5//!1    )sockmutexiddatar   vhintc                4   t          t                    }t          |          }t          t	          t
                    |          }|t          k    rFt          |t          t                               t          t          |          t          |j                  t          t                               t          |j                  }|dk    rt          t           d|           t#          ||j        d          }|dk     rFt'                      t(          k    r/t          t           dt+          t'                                           t-          |j                  }|dk    rt          t           d|           t/          |           t1          |           dS dS )a$  A pure-C function for DECREF'ing Python-owned message data.

    Sends a message on a PUSH socket

    The hint is a `zhint` struct with two values:

    sock (void *): pointer to the Garbage Collector's PUSH socket
    id (size_t): the id to be used to construct a zmq_msg_t that should be sent on a PUSH socket,
       signaling the Garbage Collector to remove its reference to the object.

    When the Garbage Collector's PULL socket receives the message,
    it deletes its reference to the object,
    allowing Python to free the memory.
    r   z!pyzmq-gc mutex lock failed rc=%d
zpyzmq-gc send failed: %s
z#pyzmq-gc mutex unlock failed rc=%d
N)r   rc   r   r   r   _zhintr	   r[   r   r   r,   rU   r   r0   r   r(   cstderrr^   r   r   r3   ro   r2   rS   r*   )r   r   msgmsg_ptrhintr}   s         r   free_python_msgr      sL   " )

C")#,,G %88D t||'6&>>222|G$$gdg&6&6vGGG
##77GA2FFF'49a0066 |||++9<
;U;U   $*%%77GCRHHHgT


q) |r   zmq_msgpointer(zmq_msg_t)bytesc                    t           }t          t          t          |                     }t	          |           }t          ||          S )zCopy the data from a zmq_msg_t)r	   r   r   rU   rb   r   )r   data_c
data_len_cs      r   _copy_zmq_msg_bytesr      s=     F&,w//00Fg&&J$VZ888r   r   pointer(p_void)writabler   c                   t          t                    }t          }|r
|t          z  }t	          | t          |          |          }|dk     rt          d          |j        |d<   |j        }t          t          |                     |S )z Get a C buffer from a memoryviewr   zCouldn't create buffer)
r   r   r   r   r   r   
ValueErrorbuflenr   )objr   r   pybufflagsr}   	data_sizes          r   	_asbufferr      s     IE'E  "3>>B	Avv1222	F1I	IWU^^$$$r   c                  t    e Zd Z	 ddZd Zd ZddZddZddZe	d             Z
e	d             Zd Zd ZdS )FrameNFc           
        t           }d}|t          j        }d}||}t          | j                  }	d| _        || _        d| _        d | _        d | _	        d | _
        d | _        |rt          j        | _        t          |t                    rt          d          |'t!          |	          }
t#          |
           d| _        d S t%          |t'          t)          t*                    t          |                              }d}||r	||k     rd}nd}n|}|rFt-          |	|          }
t#          |
           t/          t1          |	          ||           d| _        d S |r.t3                      }|| _
        t          j        |          | _        t6          ddlma t'          t)          t<                    t?          tA          t<                                        }t6          !                    || j
                  |_"        t6          j#        s8tI                      |_%        t'          tL          |j%                  t6          _#        nDt'          t)          tN                    t'          tL          t6          j#                            |_%        t'          t*          t'          tL          t6          j(        j)                            |_*        tW          |	t'          t*          |          |t'          t)          tX                    tZ                    t'          t*          |                    }
|
dk    rt]          |           t#          |
           d| _        d S )Nr   FTz8Str objects not allowed. Only: bytes, buffer interfaces.)gc)/r	   zmqCOPY_THRESHOLDr   r   more_data_failed_init_buffer_bytestracker_eventtracker_FINISHED_TRACKER
isinstancestr	TypeErrorrY   r   r   r   r   r   r[   r,   rU   r   MessageTracker_gczmq.utils.garbager   r   r+   r   storer   _push_mutexr/   r   r   r1   _push_socket
underlyingr   rZ   rN   r   r*   )selfr   trackcopycopy_thresholdkwargsr   r   c_copy_thresholdzmq_msg_ptrr}   c_copyevtr   s                 r   __init__zFrame.__init__  s    !"
! /N%&%-*1$,*?*?	 
 !  	10DLdC   	XVWWW<k**BbMMM %DFtT'&//76??%K%KLL
 < J1A$A$AF 	";
;;BbMMM<,,fjAAA %DF  	3''C!$D-c22DL
 ;333333 $WV__fVF^^6L6L M M))D$"455 	O'))DJ"64:66COOgg..VS_0M0MNNDJfc.>.I!J!JKK	  %%77
 
 77JJJbMMM!r   c                    | j         rd S t          5  t          t          | j                            }d d d            n# 1 swxY w Y   t          |           d S N)r   r   rS   r   r   r   r   r}   s     r   __dealloc__zFrame.__dealloc__w  s     	F 	= 	=%gdl&;&;<<B	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	="s   "?AAc                *    |                                  S r   )	fast_copyr   s    r   __copy__zFrame.__copy__  s    ~~r   r   c                ,   t                      }t          t          |j                  t          | j                             | j        | j        |_        | j        | j        |_        | j        | j        |_        | j        |_        | j        |_        |S r   )	r   rT   r   r   r   r   r   r   r   )r   new_msgs     r   r   zFrame.fast_copy  s     	WW_--wt|/D/DEEE :! JGM<#"lGO;"![GN !% 2,r   bufferpointer(Py_buffer)r   r~   c                ^   t          t          | j                            |_        t	          t          | j                            |_        | |_        d|_        d|_        d|_	        t          |j                  |_
        t          |_        t          |_        d|_        t          |_        d S )Nr   B   )rU   r   r   r   rb   r   r   readonlyformatndimshaper	   strides
suboffsetsitemsizeinternal)r   r   r   s      r   __getbuffer__zFrame.__getbuffer__  s    !'$,"7"788
!'$,"7"788

vz** r   r   c                H    t          t          | j                            }|S )z*Return the length of the message in bytes.)rb   r   r   )r   szs     r   __len__zFrame.__len__  s    !'$,"7"788	r   c                    | j         o|                                  }||S t          |           }t          |          | _         |S )z%A memoryview of the message contents.)r   
memoryviewr   )r   r   s     r   r   zFrame.buffer  sB     ,14<<>>NT""7||r   c                j    | j         &t          t          | j                            | _         | j         S )zThe message content as a Python bytes object.

        The first time this property is accessed, a copy of the message
        contents is made. From then on that same copy of the message is
        returned.
        )r   r   r   r   r   s    r   r   zFrame.bytes  s-     ;-gdl.C.CDDDK{r   c                Z   d}t           }t          |t                    r3t          t	          | j                  |          }t          |           |S |dk    r8t          t	          | j                            }|dk    rt          d           |S |dk    rPt          t	          | j                            }|t           k    rt          d           |	                    d          S t          dd           t          |t                    r|                    d          }t          |t                    st          d|          |}t          t           t#          t	          | j                  |                    }|t           k    rt          d           |	                    d          S )	a%  
        Get a Frame option or property.

        See the 0MQ API documentation for zmq_msg_get and zmq_msg_gets
        for details on specific options.

        .. versionadded:: libzmq-3.2
        .. versionadded:: 13.0

        .. versionchanged:: 14.3
            add support for zmq_msg_gets (requires libzmq-4.1)
            All message properties are strings.

        .. versionchanged:: 17.0
            Added support for `routing_id` and `group`.
            Only available if draft API is enabled
            with libzmq >= 4.2.
        r   
routing_idr|   grouputf8   r   zget string propertieszexpected str, got: )r	   r   rz   rV   r   r   r   r]   rX   decodery   r   encoder   r   r   r   rW   )r   optionr}   
property_cr   r   results          r   getz	Frame.get  s|   & !
 fc"" 	WT\22F;;BbMMMI\!!#5gdl6K6K#L#LJQ"w 5 566Cd{{"::f%%% 	v6777fc"" 	+]]6**F&%(( 	><&<<===
fl74<3H3H*&U&UVVT>>bMMM}}V$$$r   c                   |dk    r5|}t          t          | j                  |          }t          |           dS |dk    r]t	          |t
                    r|                    d          }t          t          | j                  |          }t          |           dS t          t          | j                  ||          }t          |           dS )am  Set a Frame option.

        See the 0MQ API documentation for zmq_msg_set
        for details on specific options.

        .. versionadded:: libzmq-3.2
        .. versionadded:: 13.0
        .. versionchanged:: 17.0
            Added support for `routing_id` and `group`.
            Only available if draft API is enabled
            with libzmq >= 4.2.
        r   Nr   r   )	ra   r   r   r   r   r   r   r`   r_   )r   r   valuer   r}   s        r   setz	Frame.set  s     \!!#(J'(=(=zJJBbMMMFw%%% -V,,"74<#8#8%@@BbMMMF..>>"r   )NFNN)r   r   )r   r   r   r~   )r   r   )__name__
__module____qualname__r   r   r   r   r   r   propertyr   r   r   r    r   r   r   r     s         AE_" _" _" _"B          ,      
   X 	 	 X	4% 4% 4%l    r   r   c                  p    e Zd ZdZdddZed	             Zeedd                        Z	d Z
ddZddZdS )Contextz
    Manage the lifecycle of a 0MQ context.

    Parameters
    ----------
    io_threads : int
        The number of IO threads.
    r   r   
io_threadsr~   shadowr   c                   t           | _        d| _        d| _        |r"t	          t
          |          | _        d| _        nd| _        t                      | _        | j        t           k    rt                      d}| j        s*t          | j        t          |          }t          |           d| _        t                      | _        d S )Nr   FT)r	   handle_pid_shadowr   r   rI   rx   rJ   r8   r   closedr.   )r   r   r   r}   s       r   r   zContext.__init__"  s    	 	(vv..DKDLL DL%--DK;$**| 	T[.*EEBbMMMHH			r   c                6    t          t          | j                  S )z,The address of the underlying libzmq contextr   r   r   r   s    r   r   zContext.underlying9       FDK(((r   r   c                    d}| j         t          k    rQ| j        sJt                      | j        k    r3t
          5  t          | j                   }d d d            n# 1 swxY w Y   t          | _         |S Nr   )r   r	   r  r.   r   r   rG   r   s     r   _termzContext._term>  s     ;$t{vxx497L7L 2 2$T[112 2 2 2 2 2 2 2 2 2 2 2 2 2 2	s   AA Ac                ~    |                                  }	 t          |           n# t          $ r Y nw xY wd| _        dS )z
        Close or terminate the context.

        This can be called to close the context by hand. If this is not called,
        the context will automatically be closed when it is garbage collected.
        TN)r  r   rw   r  r   s     r   termzContext.termH  sR     JJLL	bMMMM$ 	 	 	 D	
 s   & 
33r   c                    | j         rt          d          t          |t                    st	          d|          |}t          | j        ||          }t          |           dS )a  
        Set a context option.

        See the 0MQ API documentation for zmq_ctx_set
        for details on specific options.

        .. versionadded:: libzmq-3.2
        .. versionadded:: 13.0

        Parameters
        ----------
        option : int
            The option to set.  Available values will depend on your
            version of libzmq.  Examples include::

                zmq.IO_THREADS, zmq.MAX_SOCKETS

        optval : int
            The value of the option to set.
        Context has been destroyedexpected int, got: N)r  RuntimeErrorr   rz   r   rJ   r   r   )r   r   optvaloptval_int_cr}   s        r   r   zContext.setY  sm    0 ; 	=;<<<&#&& 	><&<<===fl;;"r   c                ~    | j         rt          d          t          | j        |          }t	          |d           |S )a'  
        Get the value of a context option.

        See the 0MQ API documentation for zmq_ctx_get
        for details on specific options.

        .. versionadded:: libzmq-3.2
        .. versionadded:: 13.0

        Parameters
        ----------
        option : int
            The option to get.  Available values will depend on your
            version of libzmq.  Examples include::

                zmq.IO_THREADS, zmq.MAX_SOCKETS

        Returns
        -------
        optval : int
            The value of the option as an integer.
        r  F)r   )r  r  rH   r   r   )r   r   r}   s      r   r   zContext.getz  sF    2 ; 	=;<<<f--"%0000	r   N)r   r   )r   r~   r   r   r   r~   r   r~   )r   r   r   __doc__r   r   r   r   r   r  r	  r   r   r   r   r   r   r     s             . ) ) X)    V U  "   B     r   r   r   c                    t          | t                    r|                     d          } 	 | }n # t          $ r t          d|           w xY w|S )Nzutf-8z"Expected addr to be str, got addr=)r   r   r   r   )addrc_addrs     r   _c_addrr    so     $ ${{7##G G G GETEEFFFGMs	   / Ac                      e Zd ZdZ	 	 	 	 d)d*d	Zed
             Zed             Zd+d,dZd-dZ	d-dZ
d.dZd/dZd.dZd.dZefd0dZd1dZd Zd2d3d%Zd2d3d&Zddd'd4d(ZdS )5Socketa2  
    A 0MQ socket.

    These objects will generally be constructed via the socket() method of a Context object.

    Note: 0MQ Sockets are *not* threadsafe. **DO NOT** share them across threads.

    Parameters
    ----------
    context : Context
        The 0MQ Context this Socket belongs to.
    socket_type : int
        The socket type, which can be any of the 0MQ socket types:
        REQ, REP, PUB, SUB, PAIR, DEALER, ROUTER, PULL, PUSH, XPUB, XSUB.

    See Also
    --------
    .Context.socket : method for creating a socket bound to a Context.
    Nr|   r   socket_typer~   r   r   c                    t           | _        t           | _        d| _        d| _        d | _        |t          j        }|| _        t           | _        || _        |r"d| _        t          t          |          | _        nL|t          d          |dk     rt          d          d| _        t          | j        j        |          | _        | j        t           k    rt                      d| _        t                      | _        d S )Nr   FTzcontext must be specifiedzsocket_type must be specified)r	   r   _draft_pollerr   r   contextr   r   r   r   r   r   rm   rx   _closedr.   )r   r  r  r   r   s        r   r   zSocket.__init__  s     !	! /N, 		GDLvv..DKK ;<<<Q ?@@@ DL$T\%8+FFDK;$**HH			r   c                6    t          t          | j                  S )z+The address of the underlying libzmq socketr  r   s    r   r   zSocket.underlying  r  r   c                     t          |           S )zWhether the socket is closed)_check_closed_deepr   s    r   r  zSocket.closed  s     "$'''r   linger
int | Nonec                   d}d}||}d}| j         t          k    r| j        st                      | j        k    r|r;t          | j         t          t          |          t          t                               | j
        t          k    r-t          t          | j
                             t          | _
        t          | j                   }|dk     r&t                      t          k    rt          |           d| _        t          | _         dS dS dS dS )a  
        Close the socket.

        If linger is specified, LINGER sockopt will be set prior to closing.

        This can be called to close the socket by hand. If this is not
        called, the socket will automatically be closed when it is
        garbage collected.
        r   FNT)r   r	   r  r.   r   rl   r9   r   r   rz   r  re   rE   r   r&   r   )r   r"  r}   	setlingerlinger_cs        r   closezSocket.close  s     	HI;$t|DI8M8M Xt{J8I8I6RU;;WWW !T))"74+=#>#>???%)"4;''BAvv*,,(22"DLDKKK 8M8Mr   r   c                P   t          |            t          |t                    rt          d          	 t	          |          }|j        }n# t          $ r t          j        }Y nw xY w|t          j	        k    r^t          |t                    st          d|          t          |          }t          |          }t          | j        |||           dS |t          j        k    rat          |t                    st          d|          |}t          | j        |t          |          t!          t"                               dS t          |t                    st          d|          |}t          | j        |t          |          t!          t                               dS )ay  
        Set socket options.

        See the 0MQ API documentation for details on specific options.

        Parameters
        ----------
        option : int
            The option to set.  Available values will depend on your
            version of libzmq.  Examples include::

                zmq.SUBSCRIBE, UNSUBSCRIBE, IDENTITY, HWM, LINGER, FD

        optval : int or bytes
            The value of the option to set.

        Notes
        -----
        .. warning::

            All options other than zmq.SUBSCRIBE, zmq.UNSUBSCRIBE and
            zmq.LINGER only take effect for subsequent socket bind/connects.
        z*unicode not allowed, use setsockopt_stringzexpected bytes, got: r  N)_check_closedr   r   r   rs   	_opt_typer   rt   rz   r   r   r    _setsockoptr   int64r   r   rC   )	r   r   r  soptopt_typeoptval_cr   optval_int64_cr  s	            r   r   z
Socket.set  s   : 	dfc"" 	JHIII	&''D ~HH  	$ 	$ 	$  |HHH		$ x~%%fe,, D B B BCCC'//Hf%%BVXr:::::''fc** B @f @ @AAA#NVW^-D-DfWooVVVVV fc** B @f @ @AAA!LVW\-B-BF3KKPPPPPs   A A%$A%c           
     <   t          t                    }t          t          j                  }t          t                    }t          t
          d                   }t          |            	 t          |          }|j        }n# t          $ r t          j        }Y nw xY w|t          j        k    rd}t          | j        |t          t          |          t!          |                     |t"          k    r-|dk    r't          t$          |          |dz
           dk    r|dz  }t'          t          t$          |          |          }	n|t          j        k    r\t+          t                    }t          | j        |t          t          t!          |                    t!          |                     |}	nk|t,          k    rE| j        t0          k    r5t3          | j        t!          |                    }
t5          |
           |}	n|t          j        k    rt+          t                    }	 t          | j        |t          t          t!          |                    t!          |                     nR# t8          $ rD}|t,          k    r-|j        t<          j        j         k    r| !                    tD                    rtG          dd           t=          j$        d          stK          d          tM          j'        t<          j(        )                                d	
           tU                      | _        | j        t0          k    r tW          | j        | j        t0          tX          tZ          z            }
t5          |
           t3          | j        t!          |                    }
t5          |
           n Y d}~nd}~ww xY w|}	nZt+          t                    }t          | j        |t          t          t!          |                    t!          |                     |}	|	S )a  
        Get the value of a socket option.

        See the 0MQ API documentation for details on specific options.

        .. versionchanged:: 27
            Added experimental support for ZMQ_FD for draft sockets via `zmq_poller_fd`.
            Requires libzmq >=4.3.2 built with draft support.

        Parameters
        ----------
        option : int
            The option to get.  Available values will depend on your
            version of libzmq.  Examples include::

                zmq.IDENTITY, HWM, LINGER, FD, EVENTS

        Returns
        -------
        optval : int or bytes
            The value of the option as a bytestring or int.
           r   r       )r   r      z)draft socket FD support via zmq_poller_fddraft'libzmq must be built with draft supportr4  )
stacklevelN).r   rC   Crz   rB   r   r)  rs   r*  r   rt   r   _getsockoptr   r   r   r   r7   r   r   r,  r   r6   r  r	   rf   r   fdrx   r   r   ErrnoEINVALr   r?   ry   hasr  warningswarnerrorDraftFDWarningrg   rd   r:   r;   )r   r   r0  r  optval_fd_cidentity_str_cr-  r.  r   r   r}   es               r   r   z
Socket.getM  s   . !))qu~~dmm c++ 	d	&''D ~HH  	$ 	$ 	$  |HHH		$ x~%%BVT&.-I-I7SU;;WWW ,&&FF&.1126:eCCa.tFN/K/KRPPFF''BVT&'.2I2I%J%JGTVKK   $FFv$"4"<"<t17;3G3GHHBbMMM FF$$B#Kfgk6J6J)K)KWUW[[        f$$39#33311 4 #!#N   77++ V*+TUUUM#)":":"<"<KKKK *8)9)9D&)T11'*DKzK?W B bMMM&t'97;;O;OPPBbMMMM "MMMM;@ !FF BVT&',2G2G%H%H'RT++   "Fs,   ,B BB'AI- -N<8D:N77N<r  str | bytesc                   t          |          }t          |            t          | j        |          }|dk    rt	                      }t                      }|r@|t          k    r5|                    dd          d         }d| d| d}t          |          |t          k    r2|                    dd          d         }d	| d
}t          |          	 	 t          |           dS # t          $ r t          | j        |          }Y 4w xY w)a2  
        Bind the socket to an address.

        This causes the socket to listen on a network port. Sockets on the
        other side of this connection will use ``Socket.connect(addr)`` to
        connect to this socket.

        Parameters
        ----------
        addr : str
            The address string. This has the form 'protocol://interface:port',
            for example 'tcp://127.0.0.1:5555'. Protocols supported include
            tcp, udp, pgm, epgm, inproc and ipc. If the address is unicode, it is
            encoded to utf-8 first.
        r   z://r   r|   z
ipc path "z" is longer than z~ characters (sizeof(sockaddr_un.sun_path)). zmq.IPC_PATH_MAX_LEN constant can be used to check addr length (if it is defined).)r   z(No such file or directory for ipc path "z".TN)r  r)  rD   r   r   r-   r$   splitrx   r%   r   rw   )r   r  r  r}   _errno_ipc_maxpathr   s           r   bindzSocket.bind  sB     !dT[&1177&LLF244H (Fl22zz%++B/? ? ? ? ? ?  3''''6!!zz%++B/IIII3''''	"
 	 )   dk622s   C( (D
	D
r   Nonec                    t          |          }t          |            	 	 t          | j        |          }t	          |           dS # t
          $ r Y 4w xY w)ar  
        Connect to a remote 0MQ socket.

        Parameters
        ----------
        addr : str
            The address string. This has the form 'protocol://interface:port',
            for example 'tcp://127.0.0.1:5555'. Protocols supported are
            tcp, udp, pgm, inproc and ipc. If the address is unicode, it is
            encoded to utf-8 first.
        TN)r  r)  rF   r   r   rw   r   r  r  r}   s       r   connectzSocket.connect  sl     !d	 f55"
 	 )   s   $A 
AAc                    t          |          }t          |            t          | j        |          }|dk    rt	                      dS )a  
        Unbind from an address (undoes a call to bind).

        .. versionadded:: libzmq-3.2
        .. versionadded:: 13.0

        Parameters
        ----------
        addr : str
            The address string. This has the form 'protocol://interface:port',
            for example 'tcp://127.0.0.1:5555'. Protocols supported are
            tcp, udp, pgm, inproc and ipc. If the address is unicode, it is
            encoded to utf-8 first.
        r   N)r  r)  rp   r   rx   rN  s       r   unbindzSocket.unbind  sH     !dt{F3377** 7r   c                    t          |          }t          |            t          | j        |          }|dk    rt	                      dS )a  
        Disconnect from a remote 0MQ socket (undoes a call to connect).

        .. versionadded:: libzmq-3.2
        .. versionadded:: 13.0

        Parameters
        ----------
        addr : str
            The address string. This has the form 'protocol://interface:port',
            for example 'tcp://127.0.0.1:5555'. Protocols supported are
            tcp, udp, pgm, inproc and ipc. If the address is unicode, it is
            encoded to utf-8 first.
        r   N)r  r)  rM   r   rx   rN  s       r   
disconnectzSocket.disconnect  sH     !d"4;7777** 7r   str | bytes | Noneeventsc                    t           }|t          |          }t          |            t          t	          | j        ||                     dS )a  
        Start publishing socket events on inproc.
        See libzmq docs for zmq_monitor for details.

        While this function is available from libzmq 3.2,
        pyzmq cannot parse monitor messages from libzmq prior to 4.0.

        .. versionadded: libzmq-3.2
        .. versionadded: 14.0

        Parameters
        ----------
        addr : str | None
            The inproc url used for monitoring. Passing None as
            the addr will cause an existing socket monitor to be
            deregistered.
        events : int
            default: zmq.EVENT_ALL
            The zmq event bitmask for which events will be sent to the monitor.
        N)r	   r  r)  r   rn   r   )r   r  rU  r  s       r   monitorzSocket.monitor2  sK    * T]]Fd$T[&&AABBBBBr   r   c                   t          dd           t          j        d          st          d          t	          |t
                    r|                    d          }|}t          | j        |          }t          |           dS )z
        Join a RADIO-DISH group

        Only for DISH sockets.

        libzmq and pyzmq must have been built with ZMQ_BUILD_DRAFT_API

        .. versionadded:: 17
        r   r4  
RADIO-DISHr5  r6  r   N)
ry   r   r=  r  r   r   r   rQ   r   r   )r   r   c_groupr}   s       r   joinzSocket.joinN  s~     	v|,,,ww 	JHIIIeS!! 	)LL((ET['22"r   c                    t          dd           t          j        d          st          d          t	          | j        |          }t          |           dS )z
        Leave a RADIO-DISH group

        Only for DISH sockets.

        libzmq and pyzmq must have been built with ZMQ_BUILD_DRAFT_API

        .. versionadded:: 17
        rY  rZ  r5  r6  N)ry   r   r=  r  rR   r   r   )r   r   r}   s      r   leavezSocket.leavea  sV     	v|,,,ww 	JHIIIdk511"r   TFr   r   r   c                   t          |            t          |t                    rt          d          |r+t          |t                    st          | j        ||          S t          |t                    r|r|j        st          d          |}nc| j	        rEt          |          }|j        }| j	        }||k     r"t          | j        ||           t          j        S t	          ||| j	                  }t          | j        ||          S )a  
        Send a single zmq message frame on this socket.

        This queues the message to be sent by the IO thread at a later time.

        With flags=NOBLOCK, this raises :class:`ZMQError` if the queue is full;
        otherwise, this waits until space is available.
        See :class:`Poller` for more general non-blocking I/O.

        Parameters
        ----------
        data : bytes, Frame, memoryview
            The content of the message. This can be any object that provides
            the Python buffer API (`memoryview(data)` can be called).
        flags : int
            0, NOBLOCK, SNDMORE, or NOBLOCK|SNDMORE.
        copy : bool
            Should the message be sent in a copying or non-copying manner.
        track : bool
            Should the message be tracked for notification that ZMQ has
            finished with it? (ignored if copy=True)

        Returns
        -------
        None : if `copy` or not track
            None if message was sent, raises an exception otherwise.
        MessageTracker : if track and not copy
            a MessageTracker object, whose `done` property will
            be False until the send is completed.

        Raises
        ------
        TypeError
            If a unicode object is passed
        ValueError
            If `track=True`, but an untracked Frame is passed.
        ZMQError
            for any of the reasons zmq_msg_send might fail (including
            if NOBLOCK is set and the outgoing queue is full).

        z$unicode not allowed, use send_stringzNot a tracked message)r   r   )r)  r   r   r   r   
_send_copyr   r   r   r   r   nbytesr   r   _send_frame)	r   r   r   r   r   r   r   ra  r   s	            r   sendzSocket.sendq  s   T 	ddC   	DBCCC 	8
4// 	8dk4777$&& S > >$%<===& 5$T**C%(ZF-1-@N.."4;U;;;"44Dd>QRRRt{C777r   c           
     J   t          |            |rt          | j        |          S t          | j        ||          }d}t	          t
                    }t          | j        t          t          t          t          |                    t          |                     ||_        |S )a  
        Receive a message.

        With flags=NOBLOCK, this raises :class:`ZMQError` if no messages have
        arrived; otherwise, this waits until a message arrives.
        See :class:`Poller` for more general non-blocking I/O.

        Parameters
        ----------
        flags : int
            0 or NOBLOCK.
        copy : bool
            Should the message be received in a copying or non-copying manner?
            If False a Frame object is returned, if True a string copy of
            message is returned.
        track : bool
            Should the message be tracked for notification that ZMQ has
            finished with it? (ignored if copy=True)

        Returns
        -------
        msg : bytes or Frame
            The received message frame.  If `copy` is False, then it will be a Frame,
            otherwise it will be bytes.

        Raises
        ------
        ZMQError
            for any of the reasons zmq_msg_recv might fail (including if
            NOBLOCK is set and no new messages have arrived).
        F)r)  
_recv_copyr   _recv_framer   r   r9  r<   r   r   r   r   )r   r   r   r   framer   r   s          r   recvzSocket.recv  s    @ 	d 
	dk5111UE::EDB[$vwt}}*E*Ewr{{   EJLr   )ra  r   c                 |}t          |            |}|dk     rt          d|d          t          |          }t          t	          t
          j                            }t          |t          |          d          }|dk    r|}n||k    rt          d|d| d          	 t          5  t          | j        |||          }	ddd           n# 1 swxY w Y   	 t          |	           |	S # t          $ r Y Uw xY w)a  
        Receive up to nbytes bytes from the socket,
        storing the data into a buffer rather than allocating a new Frame.

        The next message frame can be discarded by receiving into an empty buffer::

            sock.recv_into(bytearray())

        .. versionadded:: 26.4

        Parameters
        ----------
        buffer : memoryview
            Any object providing the buffer interface (i.e. `memoryview(buffer)` works),
            where the memoryview is contiguous and writable.
        nbytes: int, default=0
            The maximum number of bytes to receive.
            If nbytes is not specified (or 0), receive up to the size available in the given buffer.
            If the next frame is larger than this, the frame will be truncated and message content discarded.
        flags: int, default=0
            See `socket.recv`

        Returns
        -------
        bytes_received: int
            Returns the number of bytes received.
            This is always the size of the received frame.
            If the returned `bytes_received` is larger than `nbytes` (or size of `buffer` if `nbytes=0`),
            the message has been truncated and the rest of the frame discarded.
            Truncated data cannot be recovered.

        Raises
        ------
        ZMQError
            for any of the reasons `zmq_recv` might fail.
        BufferError
            for invalid buffers, such as readonly or not contiguous.
        r   znbytes=z must be non-negativeTz too big for memoryview of r   N)r)  r   r   r   r   r8  voidr   r   r   rk   r   r   rw   )
r   r   ra  r   c_flagsc_nbytesviewc_data
view_bytesr}   s
             r   	recv_intozSocket.recv_into  su   N d!a<<>>>>???&!!))(wvEE
Q;;!HH
""QQQJQQQRRR	 M M$T[&(GLLM M M M M M M M M M M M M M M" 	 )   s$   -CCCC. .
C;:C;)Nr|   r   N)r  r~   r   r   r   )r"  r#  r  )r  rE  )r  rE  r   rL  )r  rT  rU  r~   )r   rE  )r   TF)r   r   r   r   r  )r   r   r   r  r   r   r   r  r'  r   r   rK  rO  rQ  rS  r5   rW  r\  r^  rc  rh  rp  r   r   r   r  r    s        , ! ! ! ! !F ) ) X) ( ( X(         D?Q ?Q ?Q ?QBr r r rh* * * *X   4   *   , AN C C C C C8   &   @8 @8 @8 @8 @8D, , , , ,\ ./a = = = = = = = =r   r  sc                <    | j         rt          t                    dS )zDraise ENOTSUP if socket is closed

    Does not do a deep check
    N)r  rx   r&   )rq  s    r   r)  r)  $  s&     	y !x   ! !r   c           
        t          t          j                  }t          t                    }| j        rdS t          | j        t          t          t          t          |                    t          |                    }|dk     r0t                      }|t          k    r	d| _        dS |t          k    rdS nt          |           dS )zthorough check of whether the socket has been closed,
    even if by another entity (e.g. ctx.destroy).

    Only used by the `closed` property.

    returns True if closed, False otherwise
    Tr   F)r   r8  rz   r   r  rO   r   r@   r   r   r   r   r&   r4   r   )rq  styper   r}   r   s        r   r!  r!  /  s     AENNEBy tHhVWU^^ < <gbkk
 
 66LLE   	t)##u $ bMMM5r   r   r   r   c                    t          j        |          }|}	 t          5  t          t	          |j                  | |          }ddd           n# 1 swxY w Y   	 t          |           n# t          $ r Y `w xY w|S )z=Receive a message in a non-copying manner and return a Frame.)r   TN)r   r   r   r\   r   r   r   rw   )r   r   r   r   cmsgr}   s         r   rf  rf  Q  s    
 )%
 
 
 CD 	D 	Dgdl33VUCCB	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D	bMMM  % 	 	 	H	 Js#   $AAAA, ,
A98A9c                   t          t                    }t          |          }t          |          }t	          |           	 t
          5  t          || |          }ddd           n# 1 swxY w Y   	 t	          |           n)# t          $ r Y Nt          $ r t          |            w xY wt          |          }t          |           |S )z#Receive a message and return a copyTN)r   rc   r   rY   r   r   r\   rw   	ExceptionrS   r   )r   r   r   	zmq_msg_pr}   	msg_bytess         r   re  re  e  s$    i  G$+G$4$4IY''BbMMM 	8 	8i77B	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8	bMMM  % 	 	 	H 	 	 	)$$$	 $I..I)s$   
A((A,/A,4B 
B*B*r   c                    |                                 }	 t          5  t          t          |j                  | |          }ddd           n# 1 swxY w Y   	 t          |           n# t          $ r Y `w xY w|j        S )z1Send a Frame on this socket in a non-copy manner.TN)r   r   r^   r   r   r   rw   r   )r   r   r   msg_copyr}   s        r   rb  rb    s     }}H 	H 	Hgh&677GGB	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H	bMMM  % 	 	 	H	
 ;s#   $AAAA) )
A65A6c           
        t          t                    }t          t                    }t          |t	          |                    }t          t	          |          |          }t          |           	 t          5  t          t          t	          |                    |t          t	          |                               t          t	          |          | |          }ddd           n# 1 swxY w Y   	 t          |           t          t	          |                    }t          |           dS # t          $ r Y t          $ r t          t	          |                      w xY w)z5Send a message on this socket by copying its content.TN)r   rc   r   r   r   r[   r   r   r,   rU   rb   r^   rS   rw   rx  )r   r   r   r   c_bytesc_bytes_lenr}   s          r   r`  r`    s|   
 )

CfooG C!1!122K
 
73<<	5	5BbMMM 	; 	;<--wWS\\8R8RSSSgcllFE::B	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;
	bMMM ws||,,BbMMME % 	 	 	H 	 	 	'#,,'''	s%   :A$C**C.1C.6D2 2
E%>'E%r   r  r   pointer(size_t)c                p    d}	 t          | |||          }	 t          |           dS # t          $ r Y 1w xY w)zXgetsockopt, retrying interrupted calls

    checks rc, raising ZMQError on failure.
    r   TN)rO   r   rw   r   r   r  r   r}   s        r   r9  r9    Z     BFFFB77	bMMM E % 	 	 	H	   ( 
55c                p    d}	 t          | |||          }	 t          |           dS # t          $ r Y 1w xY w)zXsetsockopt, retrying interrupted calls

    checks rc, raising ZMQError on failure.
    r   TN)rl   r   rw   r  s        r   r+  r+    r  r  c                     t                      S )z6Return the integer errno of the most recent zmq error.)r   r   r   r   rq   rq     s    <<r   r   r   c                L    t          |           }|                    dd          S )z9
    Return the error string given the error number.
    r   replace)ro   r   )r   str_es     r   strerrorr    s%      &&E<<	***r   tuple[int, int, int]c                     d} d}d}t          t          |           t          |          t          |                     | ||fS )z9Return the version of ZeroMQ itself as a 3-tuple of ints.r   )rA   r   )majorminorpatchs      r   zmq_version_infor    sB    EEE@@@5%  r   
capabilityboolc                    t          dd           |                     d          }t          t          |                    S )zxCheck for zmq capability by name (e.g. 'ipc', 'curve')

    .. versionadded:: libzmq-4.1
    .. versionadded:: 14.1
    r   zzmq.hasr   )ry   r   r  rP   )r  ccaps     r   r=  r=    s;     69%%%##F++Dr   tuple[bytes, bytes]c                     t          t          d                   } t          t          d                   }t          dd           t          | |          }t	          |           | |fS )ur  generate a Z85 key pair for use with zmq.CURVE security

    Requires libzmq (≥ 4.0) to have been built with CURVE support.

    .. versionadded:: libzmq-4.0
    .. versionadded:: 14.0

    Returns
    -------
    public: bytes
        The public key as 40 byte z85-encoded bytestring.
    private: bytes
        The private key as 40 byte z85-encoded bytestring.
    @   )r   r   curve_keypair)r   r   ry   rK   r   )
public_key
secret_keyr}   s      r   r  r    s]      b""Jb""J6?+++ 
:z	2	2BbMMMz!!r   c                D   t          | t                    r|                     d          } t          |           dk    st	          d          t          t          d                   }| }t          dd           t          ||          }t          |           |dd         S )uh  Compute the public key corresponding to a secret key for use
    with zmq.CURVE security

    Requires libzmq (≥ 4.2) to have been built with CURVE support.

    Parameters
    ----------
    private
        The private key as a 40 byte z85-encoded bytestring

    Returns
    -------
    bytes
        The public key as a 40 byte z85-encoded bytestring
    r   (   z/secret key must be a 40 byte z85 encoded stringr  rY  curve_publicN)
r   r   r   r   r   r   r   ry   rL   r   )r  r  c_secret_keyr}   s       r   r  r    s      *c"" /&&v..
z??b  JKKK b""J",L6>*** 
*l	3	3BbMMMcrc?r   timeoutc           	        t           }t          |           }|dk    rg S t          t          t                    t          |t          t                    z                      }|t           k    rt          d          t          |          D ]y}| |         \  }}t          |t                    rMt          t          |          j        ||         _        d||         _        |||         _        d||         _        pt          |t                     r<|}t           ||         _        |||         _        |||         _        d||         _        t#          |d          r	 t!          |                                          }t           ||         _        |||         _        |||         _        d||         _        .# t&          $ r t)          |           t+          d          w xY wt)          |           t-          d|          d}	 	 t/                      }	t0          5  t3          |||          }
ddd           n# 1 swxY w Y   	 t5          |
           nr# t6          $ re |dk    r\t/                      }t!          d||	z
  z            }|dk     r t9          j        d	| d
t<                     d}t?          d||z
            }Y w xY wn# t&          $ r t)          |            w xY wg }t          |          D ]^}||         j        }|dk    rI||         j        t           k    r| |         d         }n||         j        }|                     ||f           _t)          |           |S )ae  zmq_poll(sockets, timeout=-1)

    Poll a set of 0MQ sockets, native file descs. or sockets.

    Parameters
    ----------
    sockets : list of tuples of (socket, flags)
        Each element of this list is a two-tuple containing a socket
        and a flags. The socket may be a 0MQ socket or any object with
        a ``fileno()`` method. The flags can be zmq.POLLIN (for detecting
        for incoming messages), zmq.POLLOUT (for detecting that send is OK)
        or zmq.POLLIN|zmq.POLLOUT for detecting both.
    timeout : int
        The number of milliseconds to poll for. Negative means no timeout.
    r   zCould not allocate poll itemsfilenoz'fileno() must return a valid integer fdzFSocket must be a 0MQ socket, an integer fd or have a fileno() method: TNi  z,Negative elapsed time for interrupted poll: z.  Did the clock change?)!r	   r   r   r   rh   r+   r   MemoryErrorranger   r  r   socketr:  rU  reventsrz   hasattrr  rx  r*   r   r   r   r   
zmq_poll_cr   rw   r>  r?  RuntimeWarningmaxappend)socketsr  	pollitemsnsocketsirq  rU  r  	ms_passedstartr}   ticresultsr  s                 r   rr   rr   <  s   ( *.I'llH1}}	W^,,fX~@V@V5V.W.WXXID9:::8__  AJ	6a   	"&vq//"8IaLIaLO"(IaL#$IaL  3 	F"&IaL$IaLO"(IaL#$IaL  Q!! 		)QXXZZ
 '+	!#"(	!&,	!#'(	!$$  L L LY !JKKKL OOO,&', ,  
 I	$;;E > >	8W==> > > > > > > > > > > > > > >"& % )   Q;;#++C #DC%K$8 9 9I 1}} !69 6 6 6*   %&	!!Wy%899G!$    Y G8__ 
) 
)A,& Q;;|"d**AJqMaLONNAw<(((OOONsa   !F::)G#
K  H>2K >IK IK 
I K A,K	K K		K K(frontendbackendcapturec                
   d}t          |t                    r|j        }nt          }	 t          5  t          | j        |j        |          }ddd           n# 1 swxY w Y   	 t          |           n# t          $ r Y Xw xY w|S )a~  
    Start a zeromq proxy (replacement for device).

    .. versionadded:: libzmq-3.2
    .. versionadded:: 13.0

    Parameters
    ----------
    frontend : Socket
        The Socket instance for the incoming traffic.
    backend : Socket
        The Socket instance for the outbound traffic.
    capture : Socket (optional)
        The Socket instance for capturing traffic.
    r   TN)r   r  r   r	   r   ri   r   rw   )r  r  r  r}   capture_handles        r   proxyr    s      B'6""   	L 	L8?GNNKKB	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L	bMMM  % 	 	 	H	 Is#   AAA#A3 3
B ?B controlc                T   d}t          |t                    r|j        }nt          }t          |t                    r|j        }nt          }	 t          5  t          | j        |j        ||          }ddd           n# 1 swxY w Y   	 t          |           n# t          $ r Y Yw xY w|S )a  
    Start a zeromq proxy with control flow.

    .. versionadded:: libzmq-4.1
    .. versionadded:: 18.0

    Parameters
    ----------
    frontend : Socket
        The Socket instance for the incoming traffic.
    backend : Socket
        The Socket instance for the outbound traffic.
    capture : Socket (optional)
        The Socket instance for capturing traffic.
    control : Socket (optional)
        The Socket instance for control flow.
    r   TN)r   r  r   r	   r   rj   r   rw   )r  r  r  r  r}   r  control_handles          r   proxy_steerabler    s   . B'6""  '6""  
 	 	$ B	 	 	 	 	 	 	 	 	 	 	 	 	 	 		bMMM  % 	 	 	H	 Is$   A<<B B B 
B%$B%	in_socket
out_socketside_socketrc   side_msgid_msgswap_idsc                   t          t                    }t          t                    }t          t                    }|r\t	          t          |          | d          }	|	dk     r|	S t	          t          |          | d          }	|	dk     r|	S t          t          |          t          |                    }	|	dk     r|	S t          t          |          |t                    }	|	dk     r|	S t          t          |          |t                    }	|	dk     r|	S t          t          |          t          |                    }	|	dk     r|	S t          t          |          |t                    }	|	dk     r|	S t          t          |          |t                    }	|	dk     r|	S 	 t	          t          |          | d          }	|	dk     r|	S t          | t          t          |          t          |                    }	|	dk     r|	S d}
|r
|
t          z  }
t          t          |          t          |                    }	|	dk     r|	S |
rRt          t          |          ||
          }	|	dk     r|	S t          t          |          |t                    }	|	dk     r|	S nMt          t          |          |d          }	|	dk     r|	S t          t          |          |d          }	|	dk     r|	S nB|	S r  )r   r   rz   r   r\   r   rT   r^   r>   rO   r<   )r  r  r  r   r  r  r  flagszr   r}   r   s              r   	_mq_relayr    s    V__F3<<DC[[F '#,,	15566I'&//9a8866I '(++WV__==66I'(++ZEE66I'&//;DD66I'(++WS\\::66I'(++ZEE66I'#,,[AA66I'#,,	15566II{GDMM76??SS66I 	![ E'(++WS\\::66I 	gh//UCCBAvv	gcllKEEBAvv	  gh//Q??BAvv	gcllK;;BAvv	=> Ir   
in_msg_ptrout_msg_ptrc           	        t          t                    }t          t          |                    }t          t                    }t          t          |                    }|dk     r|S t          t                    }	t          t          |	                    }|dk     r|S t          t          d                   }
| |
d         _        t          |
d         _        dx|
d         _        |
d         _	        ||
d         _        t          |
d         _        dx|
d         _        |
d         _	        	 t          t          |
d                   dd          }|dk     r|S |
d         j	        t          z  rmt          t          |	          |          }|dk     r|S t          t          |	          |t                    }|dk     r|S t          | ||||	||          }|dk     r|S |
d         j	        t          z  rmt          t          |	          |          }|dk     r|S t          t          |	          |t                    }|dk     r|S t          || |||	||          }|dk     r|S 2)z.
    inner C function for monitored_queue
    r   r4  r   Tr|   )r   rc   rY   r   rh   r  r:   rU  r:  r  r  rT   r^   r>   r  )r  r  r  r  r  r  r   r}   r  r  itemss              r   
_mq_inliner  P  s@    Y''CWS\\**BYF	gfoo	&	&B	Avv	y!!H	gh''	(	(B	Avv	N1%&&EE!HO E!HO%&&E!HK%(" E!HO E!HO%&&E!HK%(" a))1b1166I8j( 	gh//<<BAvv	gh//kJJBAvv	:{C68 B Avv	8j( 	gh//==BAvv	gh//kJJBAvv	I{C68 B Avv	A r      in   out
mon_socket	in_prefix
out_prefixc           
        | j         }|j         }|j         }t          t                    }t          t                    }	t          }
t          t                    }| j        t          k    o|j        t          k    }t          |t          |
                    }t          t          |          |          }t          |           t          t          t          |                    |
t          t          |                               t          |t          |
                    }t          t          |	          |          }t          |           	 t          5  t          t          t          |	                    |
t          t          |	                               t          |||t          |          t          |	          |          }ddd           n# 1 swxY w Y   	 t          |           n# t           $ r Y w xY w|S )a  
    Start a monitored queue device.

    A monitored queue is very similar to the zmq.proxy device (monitored queue came first).

    Differences from zmq.proxy:

    - monitored_queue supports both in and out being ROUTER sockets
      (via swapping IDENTITY prefixes).
    - monitor messages are prefixed, making in and out messages distinguishable.

    Parameters
    ----------
    in_socket : zmq.Socket
        One of the sockets to the Queue. Its messages will be prefixed with
        'in'.
    out_socket : zmq.Socket
        One of the sockets to the Queue. Its messages will be prefixed with
        'out'. The only difference between in/out socket is this prefix.
    mon_socket : zmq.Socket
        This socket sends out every message received by each of the others
        with an in/out prefix specifying which one it was.
    in_prefix : str
        Prefix added to broadcast messages from in_socket.
    out_prefix : str
        Prefix added to broadcast messages from out_socket.
    TN)r   r   rc   r	   r
   typer=   r   r   r[   r   r,   rU   rb   r   r  rw   )r  r  r  r  r  insoutsmonsin_msgout_msgmsg_c	msg_c_lenr  r}   s                 r   monitored_queuer    s   D "C$D$DYFi  GE
##I ~+M
:0MH )WU^^44I	76??I	6	6BbMMM
<((%gfoo1N1NOOO*genn55I	77++Y	7	7BbMMM 	 	WW--..|GGDTDT7U7U   T4''2B2BH B		 	 	 	 	 	 	 	 	 	 	 	 	 	 		bMMM  % 	 	 	H	 Is%   A4GGG$G4 4
H H)r{   r   r  r   r=  r  r  r  rq   rr   r  r  r  )F)r}   r~   r   r   r   r~   )r   r   r   r   r   r~   )r   r   r   r   )r   r   r   r   r   r   )r   r   )rq  r  )rq  r  r   r   )r   F)r   r   r   r~   r   r   r   r   )r   )r   r   r   r~   )r   r   r   r   r   r~   )r   r   r   r~   r  r   r   r  )r   r   r   r~   r  r   r   r   r  )r   r~   r   r   )r   r  )r  r   r   r  )r   r  )r   r   )r|   )r  r~   r   )r  r  r  r  r  r  )NN)r  r  r  r  r  r  r  r  )r  r   r  r   r  r   r   rc   r  rc   r  rc   r  r   r   r~   )r  r   r  r   r  r   r  r   r  r   r  r   r   r~   )r  r  )
r  r  r  r  r  r  r  r   r  r   )r  
__future__r   cythoncompiledImportErrorpathlibr   __file__parentszmq_rootr   r>  	threadingr   timer   weakrefr   r8  r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   cython.cimports.cpython.bufferr   r   r   r   r   cython.cimports.cpython.bytesr   r   r    cython.cimports.cpython.excr!   cython.cimports.libc.errnor"   r#   r$   r%   r&   cython.cimports.libc.stdintr'   cython.cimports.libc.stdior(   r)   r   cython.cimports.libc.stdlibr*   r+   cython.cimports.libc.stringr,   +cython.cimports.zmq.backend.cython._externsr-   r.   r/   r0   r1   r2   )cython.cimports.zmq.backend.cython.libzmqr3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   r   rr   r  r   zmq.constantsrs   rt   	zmq.errorru   rv   rw   rx   ry   r{   __annotations__	exceptvalr   structr   r   r   r   r   r   r   r  r  r)  r!  rf  re  rb  r`  r9  r+  r  r  r=  r  r  r  r  r  r  r  __all__r   r   r   <module>r     s"     
 # " " " " "MMM? kmm   tH~~%a(H "  "  C +c

'*                                                          $                      
 ; : : : : : T T T T T T T T T T T T T T 0 0 0 0 0 0 . . . . . . 8 8 8 8 8 8 4 4 4 4 4 4 4 4 . . . . . .               ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?@ N M M M M M L L L L L L 



 0 0 0 0 0 0 0 0              -,..  . . . . R      . 
	
''


 
 
 ( ( (  (V 9 9 9  9               D @ @ @ @ @ @ @ @F      v	 v	 v	 v	 v	 v	 v	 v	x ! ! !  !     @      $      0      ,      @           &   
+ + + +! ! ! !   " " " "4   Bk k k k k\    J 	, , , , ,b M M M   M` @ @ @   @N I I I I IX  s	   ! 6A