
    ^h                       % S r SSKJr   SSKr\R                  (       d  \" 5       e SSKrSS	KJr  SS
KJr  SSKJr  SSKrSSKJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#  SSK$J%r%J&r&J'r'J(r(J)r)  SSK*J+r+J,r,J-r-  SSK.J/r/  SSK0J1r1J2r2J3r3J4r4J5r5  SSK6J7r7  SSK8J9r9  SSK8J:r;  SSK<J=r=J>r>  SSK?J@r@  SSKAJBrB  SSKCJDrDJErEJFrFJGrGJHrHJIrI  SSKJJKrKJLrLJMrMJNrNJOrOJPrPJQrQJRrRJSrSJTrTJUrUJVrVJWrWJXrXJYrYJZrZJ[r[J\r\J]r]J^r^J_r_J`r`JaraJbrbJcrcJdrdJereJfrfJgrgJhrhJiriJjrjJkrkJlrlJmrmJnrnJoroJprpJqrqJrrrJsrsJtrtJuruJvrvJwrwJxrxJyryJzrzJ{r{J|r|J}r}J~r~JrJrJrJrJrJrJrJrJrJr  SSKJJr  SSKJJr  SSKrSSKJrJr  SSKJrJrJrJrJr  \D" 5       rS\S'   \" \BGR4                  5      rS\S '   \\\GR6                  " S!5      SCSDS" jj5       5       5       r\GR:                  " \ \!" \H5      \"S#9r\\SES$ j5       5       r\\SFS% j5       5       r\\SCSGS& jj5       5       rSq\ " S' S(5      5       r\ " S) S*5      5       r\\SHS+ j5       5       r\ " S, S-5      5       r\\SIS. j5       5       r\\SJS/ j5       5       r\\SKSLS0 jj5       5       r\\SMSNS1 jj5       5       r\\SMSOS2 jj5       5       r\\SMSNS3 jj5       5       r\\SPS4 j5       5       r\\SQS5 j5       5       rSRS6 jrSSS7 jrSTS8 jrSUS9 jrSVS: jrSHS; jrSWSXS< jjrSYSZS= jjr  S[       S\S> jjr\\\                S]S? j5       5       5       r\\\              S^S@ j5       5       5       r  S_         S`SA jjr/ SBQrg! \ a-    SSKJr  \" \5      R                  S   r
S\
 S\
 S3r\" \5      ef = f)az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)libzmq)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_LENboolPYZMQ_DRAFT_APIc                    [        5       n[        5         US:X  a  U(       d  gU S:X  aJ  U[        :X  a  [        U5      eU[        :X  a  [        U5      eU[        :X  a  [        U5      e[        U5      eg)z`internal utility for checking zmq return condition

and raising the appropriate Exception class
r   r   )	
_zmq_errnor!   r#   rx   r"   rv   r5   rw   ry   )rcerror_without_errnoerrnos      Q/home/james-whalen/.local/lib/python3.13/site-packages/zmq/backend/cython/_zmq.py	_check_rcr      sh     <Ez-	RxE>'..f_,i#E**5/!    )sockmutexidc                   [        [        5      n[        U5      n[        [	        [
        5      U5      nU[        :w  Ga  [        U[        [        5      5        [        [        U5      [        UR                  5      [        [        5      5        [        UR                  5      nUS:w  a  [        [         SU5        [#        X4R$                  S5      nUS:  a4  ['        5       [(        :w  a"  [        [         S[+        ['        5       5      5        [-        UR                  5      nUS:w  a  [        [         SU5        [/        U5        [1        U5        gg)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   rd   r   r   r   _zhintr	   r\   r   r   r,   rV   r   r1   r   r(   cstderrr_   r   r   r4   rp   r3   rT   r*   )datavhintmsgmsg_ptrhintr   s         r   free_python_msgr      s    " )
C")#,G %8D t|'6&>2|G$gdgg&6vG

#7GA2F'99a06 ||+9<
;U $**%7GCRHgT
) r   c                l    [         n[        [        [        U 5      5      n[	        U 5      n[        X5      $ )zCopy the data from a zmq_msg_t)r	   r   r   rV   rc   r   )zmq_msgdata_c
data_len_cs      r   _copy_zmq_msg_bytesr      s/     F&,w/0Fg&J$V88r   c                    [        [        5      n[        nU(       a	  U[        -  n[	        U [        U5      U5      nUS:  a  [        S5      eUR                  US'   UR                  n[        [        U5      5        U$ )z Get a C buffer from a memoryviewr   zCouldn't create buffer)
r   r   r   r   r   r   
ValueErrorbuflenr   )objr   writablepybufflagsr   	data_sizes          r   	_asbufferr     sm     IE'E"3>B	Av122		F1I		IWU^$r   c                  v    \ rS rSr SS jrS rS rSS jrSS jrSS jr	\
S	 5       r\
S
 5       rS rS rSrg)Framei  Nc           
        [         nSnUc  [        R                  nSnUb  Un[        U R                  5      n	SU l        Xl        SU l        S U l        S U l	        S U l
        S U l        U(       a  [        R                  U l        [        U[        5      (       a  [        S5      eUc  [!        U	5      n
[#        U
5        SU l        g [%        U['        [)        [*        5      [        U5      5      5      nSnUc  U(       a  Xx:  a  SnOSnOUnU(       a3  [-        X5      n
[#        U
5        [/        [1        U	5      Xg5        SU l        g U(       a+  [3        5       nXl
        [        R4                  " U5      U l        [6        c  SSKJq  ['        [)        [<        5      [?        [A        [<        5      5      5      n[6        RC                  XR                  5      Ul"        [6        RF                  (       d3  [I        5       Ul%        ['        [L        URJ                  5      [6        l#        O:['        [)        [N        5      ['        [L        [6        RF                  5      5      Ul%        ['        [*        ['        [L        [6        RP                  RR                  5      5      Ul*        [W        U	['        [*        U5      U['        [)        [X        5      [Z        5      ['        [*        U5      5      n
U
S:w  a  []        U5        [#        U
5        SU l        g )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	TypeErrorrZ   r   r   r   r   r   r\   r,   rV   r   MessageTracker_gczmq.utils.garbager   r   r+   r   storer   _push_mutexr0   r   r   r2   _push_socket
underlyingr   r[   rO   r   r*   )selfr   trackcopycopy_thresholdkwargsr   r   c_copy_thresholdzmq_msg_ptrr   c_copyevtr   s                 r   __init__Frame.__init__  s;    !"
! //N%&%-*1$,,*?	 
 ! 00DLdC  VWW<k*BbM %DtT'&/76?%KL
 <J$AF";;BbM<,fA %D 'C!$--c2DL
 ;3 $WV_fVF^6L M))D"4"45')DJ"64::6COgg.VS__0MNDJfc.>.>.I.I!JK	 %7
 7JbM!r   c                    U R                   (       a  g [           [        [        U R                  5      5      nS S S 5        [        W5        g ! , (       d  f       N= fN)r   r   rT   r   r   r   r   r   s     r   __dealloc__Frame.__dealloc__z  s8    %gdll&;<B " Us   A
Ac                "    U R                  5       $ r   )	fast_copyr   s    r   __copy__Frame.__copy__  s    ~~r   c                v   [        5       n[        [        UR                  5      [        U R                  5      5        U R                  b  U R                  Ul        U R
                  b  U R
                  Ul        U R                  b  U R                  Ul        U R                  Ul        U R                  Ul        U$ r   )	r   rU   r   r   r   r   r   r   r   )r   new_msgs     r   r   Frame.fast_copy  s     	WW__-wt||/DE ::! JJGM<<#"llGO;;"![[GN !% 2 2,,r   c                J   [        [        U R                  5      5      Ul        [	        [        U R                  5      5      Ul        Xl        SUl        SUl        SUl	        [        UR
                  5      Ul
        [        Ul        [        Ul        SUl        [        Ul        g )Nr   B   )rV   r   r   r   rc   r   r   readonlyformatndimshaper	   strides
suboffsetsitemsizeinternal)r   bufferr   s      r   __getbuffer__Frame.__getbuffer__  ss    !'$,,"78
!'$,,"78

vzz* r   c                B    [        [        U R                  5      5      nU$ )z*Return the length of the message in bytes.)rc   r   r   )r   szs     r   __len__Frame.__len__  s    !'$,,"78	r   c                    U R                   =(       a    U R                  5       nUb  U$ [        U 5      n[        U5      U l         U$ )z%A memoryview of the message contents.)r   
memoryviewr   )r   r   s     r   r   Frame.buffer  s=     ,,14<<>NT"7|r   c                z    U R                   c#  [        [        U R                  5      5      U l         U R                   $ )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   bytesFrame.bytes  s-     ;;-gdll.CDDK{{r   c                   Sn[         n[        U[        5      (       a,  [        [	        U R
                  5      U5      n[        U5        U$ US:X  a1  [        [	        U R
                  5      5      nUS:X  a  [        S5        U$ US:X  aD  [        [	        U R
                  5      5      nU[         :X  a  [        S5        UR                  S5      $ [        SS5        [        U[        5      (       a  UR                  S5      n[        U[        5      (       d  [        SU< 35      eUn[        [         [#        [	        U R
                  5      U5      5      nU[         :X  a  [        S5        UR                  S5      $ )	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   r{   rW   r   r   r   r^   rY   decoderz   r   encoder   r   r   r   rX   )r   optionr   
property_cr   r   results          r   get	Frame.get  s+   & !
 fc""WT\\2F;BbMI\!#5gdll6K#LJQ"w 56Cd{"::f%% 	v67fc""]]6*F&%((1&<==
fl74<<3H*&UVT>bM}}V$$r   c                l   US:X  a-  Un[        [        U R                  5      U5      n[        U5        gUS:X  aQ  [	        U[
        5      (       a  UR                  S5      n[        [        U R                  5      U5      n[        U5        g[        [        U R                  5      X5      n[        U5        g)a%  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   )	rb   r   r   r   r   r   r   ra   r`   )r   r   valuer   r   s        r   set	Frame.set  s     \!#(J'(=zJBbMw%%%V,"74<<#8%@BbM.>"r   )r   r   r   r   r   r   r   )NFNN)returnr   )r   zpointer(Py_buffer)r   C.int)r   r   )__name__
__module____qualname____firstlineno__r   r   r   r   r   r   propertyr   r   r   r   __static_attributes__ r   r   r   r     s\     AE_"B ,
   	 	4%lr   r   c                  n    \ rS rSrSrSSS jjr\S 5       r\\	SS j5       5       r
S rSS jrSS jrS	rg
)Contexti  zn
Manage the lifecycle of a 0MQ context.

Parameters
----------
io_threads : int
    The number of IO threads.
c                   [         U l        SU l        SU l        U(       a  [	        [
        U5      U l        SU l        OSU l        [        5       U l        U R                  [         :X  a
  [        5       eSnU R                  (       d&  [        U R                  [        U5      n[        U5        SU l        [        5       U l        g )Nr   FT)r	   handle_pid_shadowr   r   rJ   ry   rK   r9   r   closedr/   )r   
io_threadsshadowr   s       r   r   Context.__init__%  s    	vv.DKDL DL%-DK;;$*||T[[.*EBbMH	r   c                6    [        [        U R                  5      $ )z,The address of the underlying libzmq contextr   r   r  r   s    r   r   Context.underlying<       FDKK((r   c                   SnU R                   [        :w  aM  U R                  (       d<  [        5       U R                  :X  a$  [
           [        U R                   5      nS S S 5        [        U l         U$ ! , (       d  f       N= fNr   )r  r	   r  r/   r	  r   rH   r   s     r   _termContext._termA  sR     ;;$t{{vx4997L$T[[1 	 s   A11
A?c                j    U R                  5       n [        U5        SU l        g! [         a     Nf = f)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   rx   r  r   s     r   termContext.termK  s:     JJL	bM  % 	 	s   % 
22c                    U R                   (       a  [        S5      e[        U[        5      (       d  [	        SU< 35      eUn[        U R                  X5      n[        U5        g)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   r{   r   rK   r  r   )r   r   optvaloptval_int_cr   s        r   r   Context.set\  sS    0 ;;;<<&#&&1&<==f;"r   c                ~    U R                   (       a  [        S5      e[        U R                  U5      n[	        USS9  U$ )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  rI   r  r   )r   r   r   s      r   r   Context.get}  s6    2 ;;;<<f-"%0	r   )r	  r
  r  r  N)r   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  r    sL    . ) )   "Br   r  c                    [        U [        5      (       a  U R                  S5      n  U nU$ ! [         a    [        SU < 35      ef = f)zmcast an address input to bytes

Expects a str, but accepts bytes
and raises informative TypeError otherwise.
zutf-8z"Expected addr to be str, got addr=)r   r   r   r   )addrc_addrs     r   _c_addrr)    sW     ${{7#G M  G<THEFFGs	   , Ac                      \ rS rSrSr    S   SS jjr\S 5       r\S 5       rSSS jjr	SS	 jr
SS
 jrSS jrSS jrSS jrSS jr\4SS jjrSS jrS rS S!S jjrS S!S jjrSSS.S"S jjrSrg)#Socketi  a  
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   c                   [         U l        [         U l        SU l        SU l        S U l        Uc  [        R                  nX@l        [         U l        Xl        U(       a  SU l        [        [        U5      U l        OKUc  [        S5      eUS:  a  [        S5      eSU l        [        U R
                  R                  U5      U l        U R                  [         :X  a
  [        5       eSU l        [        5       U l        g )Nr   FTzcontext must be specifiedzsocket_type must be specified)r	   r  _draft_pollerr	  r
  contextr   r   r   r   r   r   rn   ry   _closedr/   )r   r.  socket_typer  r   s        r   r   Socket.__init__  s     !	! //N,DLvv.DK ;<<Q ?@@ DL$T\\%8%8+FDK;;$*H	r   c                6    [        [        U R                  5      $ )z+The address of the underlying libzmq socketr  r   s    r   r   Socket.underlying  r  r   c                    [        U 5      $ )zWhether the socket is closed)_check_closed_deepr   s    r   r  Socket.closed  s     "$''r   c                   SnSnUb  UnSnU R                   [        :w  a  U R                  (       d  [        5       U R                  :X  a  U(       a2  [        U R                   [        [        W5      [        [        5      5        U R                  [        :w  a)  [        [        U R                  5      5        [        U l
        [        U R                   5      nUS:  a  [        5       [        :w  a  [        U5        SU l        [        U l         gggg)z
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	  rm   r:   r   r   r{   r-  rf   rF   r   r&   r   )r   lingerr   	setlingerlinger_cs        r   closeSocket.close  s     	HI;;$t||DII8Mt{{J8I6RU;W !!T)"74+=+=#>?%)"4;;'BAv*,(2"DLDK 9N|r   c                   [        U 5        [        U[        5      (       a  [        S5      e [	        U5      nUR
                  nU[        R                  :X  aR  [        U[        5      (       d  [        SU< 35      e[        U5      n[        U5      n[        U R                  XU5        gU[        R                  :X  aU  [        U[        5      (       d  [        SU< 35      eUn[        U R                  U[        U5      [!        ["        5      5        g[        U[        5      (       d  [        SU< 35      eUn[        U R                  U[        U5      [!        [        5      5        g! [         a    [        R                  n GNAf = f)a  
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   rt   	_opt_typer   ru   r{   r   r   r    _setsockoptr  int64r   r   rD   )	r   r   r  soptopt_typeoptval_cr   optval_int64_cr  s	            r   r   
Socket.set  s9   : 	dfc""HII	&'D ~~Hx~~%fe,,"7z BCC'/Hf%BVr:'fc**"5fZ @AA#NVW^-DfWoV fc**"5fZ @AA!LVW\-BF3KP9  	$  ||H		$s   E( (FFc           
        [        [        5      n[        [        R                  5      n[        [        5      n[        [
        S   5      n[        U 5         [        U5      nUR                  nU[        R                  :X  a|  Sn[        U R                  U[        [        U5      [!        U5      5        U["        :w  a%  US:  a  [        [$        U5      US-
     S:X  a  US-  n['        [        [$        U5      U5      n	U	$ U[        R(                  :X  aK  [+        [        5      n[        U R                  U[        [        [!        U5      5      [!        U5      5        Un	U	$ U[,        :X  aB  U R.                  [0        :w  a.  [3        U R.                  [!        U5      5      n
[5        U
5        Un	U	$ U[        R6                  :X  aL  [+        [        5      n [        U R                  U[        [        [!        U5      5      [!        U5      5        Un	U	$ [+        [        5      n[        U R                  U[        [        [!        U5      5      [!        U5      5        Un	U	$ ! [         a    [        R                  n GNf = f! [8         GaA  nU[,        :X  Ga0  UR:                  [<        R>                  R@                  :X  Ga  U RC                  [D        5      (       a  [G        SS5        [<        RH                  (       d  [K        S5      e[L        RN                  " [<        RP                  RS                  5       SS	9  [U        5       U l        U R.                  [0        :X  a  e [W        U R.                  U R                  [0        [X        [Z        -  5      n
[5        U
5        [3        U R.                  [!        U5      5      n
[5        U
5         S
nAGNe S
nAff = f)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_fd1libzmq and pyzmq must be built with draft supportrJ  )
stacklevelN).r   rD   Cr{   rC   r   r>  rt   r?  r   ru   r   _getsockoptr  r   r   r   r8   r   r   rA  r   r7   r-  r	   rg   r   fdry   r   r   ErrnoEINVALr   r@   rz   	DRAFT_APIr  warningswarnerrorDraftFDWarningrh   re   r;   r<   )r   r   rE  r  optval_fd_cidentity_str_crB  rC  r   r   r   es               r   r   
Socket.getU  s    . !)quu~dm c+ 	d	&'D ~~Hx~~%BVT&.-I7SU;W ,&F&.126:eCa.tFN/KRPFB A 'BVT&'.2I%JGTVK $Fv u v$"4"4"<t117;3GHBbM Fl k $B%KKfgk6J)KWUW[J !F  BVT&',2G%H'RT+ "Fg  	$  ||H		$H  ! f$399#3#3311"!#N ==*O  MM#))":":"<K *8)9D&))T1'**DKKzK?WB bM&t'9'97;;OPBbMMC!s1   I 8I4 I10I14O ?D5N;:N;;O c                   [        U5      nUn[        U 5        [        U R                  U5      nUS:w  az  [	        5       n[        5       nU(       a1  U[        :X  a'  UR                  SS5      S   nSU SU S3n[        US9eU[        :X  a$  UR                  SS5      S   nS	U S
3n[        US9e  [        U5        g! [         a    [        U R                  U5      n M1  f = f)a  
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".N)r)  r>  rE   r  r   r.   r$   splitry   r%   r   rx   )	r   r'  _addr_bytesr(  r   _errno_ipc_maxpathr   s	            r   bindSocket.bind  s      %T]$dT[[&17&LF24HFl2zz%+B/ &7z B? ?  3''6!zz%+B/@bI3''"
 	 ) dkk62s   1B= = C! C!c                    [        U5      nUn[        U 5          [        U R                  U5      n[	        U5        g! [
         a     M1  f = f)a*  
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.
N)r)  r>  rG   r  r   rx   r   r'  r]  r(  r   s        r   connectSocket.connect  sR     %T]$d f5"
 	 ) s   != 
A
Ac                    [        U5      nUn[        U 5        [        U R                  U5      nUS:w  a
  [	        5       eg)ao  
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>  rq   r  ry   rd  s        r   unbindSocket.unbind  s>     %T]$dt{{F37* r   c                    [        U5      nUn[        U 5        [        U R                  U5      nUS:w  a
  [	        5       eg)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>  rN   r  ry   rd  s        r   
disconnectSocket.disconnect)  s>     %T]$d"4;;77* r   c                    [         nUb  [        U5      nUn[        U 5        [        [	        U R
                  X25      5        g)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   ro   r  )r   r'  eventsr(  r]  s        r   monitorSocket.monitor@  s9    * !(K(Fd$T[[&ABr   c                    [        SS5        [        R                  (       d  [        S5      e[	        U[
        5      (       a  UR                  S5      nUn[        U R                  U5      n[        U5        g)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   rJ  
RADIO-DISHrK  r   N)
rz   r   rR  r  r   r   r   rR   r  r   )r   r   c_groupr   s       r   joinSocket.join]  sX     	v|,}}RSSeS!!LL(ET[['2"r   c                    [        SS5        [        R                  (       d  [        S5      e[	        U R
                  U5      n[        U5        g)z
Leave a RADIO-DISH group

Only for DISH sockets.

libzmq and pyzmq must have been built with ZMQ_BUILD_DRAFT_API

.. versionadded:: 17
rr  rs  rK  N)rz   r   rR  r  rS   r  r   )r   r   r   s      r   leaveSocket.leavep  s8     	v|,}}RSSdkk51"r   c                D   [        U 5        [        U[        5      (       a  [        S5      eU(       a+  [        U[        5      (       d  [        U R                  X5      $ [        U[        5      (       a&  U(       a  UR                  (       d  [        S5      eUnOsU R                  (       aN  [        U5      nUR                  nU R                  nXx:  a&  [        U R                  Xb5        [        R                  $ [	        XU R                  S9n[        U R                  XR5      $ )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   r|  r   s	            r   sendSocket.send  s    T 	ddC  BCC
4//dkk477$&&$%<==&&$T*C%(ZZF-1-@-@N."4;;;"444Dd>Q>QRt{{C77r   c           
     (   [        U 5        U(       a  [        U R                  U5      $ [        U R                  X5      nSn[	        [
        5      n[        U R                  [        [        [        [        U5      5      [        U5      5        XTl        U$ )aJ  
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   rN  r=   r   r   r   r   )r   r   r   r   framer   r   s          r   recvSocket.recv  so    @ 	ddkk511U:EDB[$vwt}*Ewr{ JLr   )r|  r   c                 Un[        U 5        UnUS:  a  [        SU< S35      e[        U5      n[        [	        [
        R                  5      5      n[        U[        U5      S5      nUS:X  a  UnOXX:  a  [        SU< SU S35      e [           [        U R                  XuU5      n	SSS5         [        W	5        U	$ ! , (       d  f       N= f! [         a     MS  f = f)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   rM  voidr   r   r   rl   r  r   rx   )
r   r   r|  r   c_flagsc_nbytesviewc_data
view_bytesr   s
             r   	recv_intoSocket.recv_into  s    N d!a<y(=>??&!)(wvE
Q;!H"y(CJ<qQRR $T[[&GL " 	  ) s   B?2C ?
C
CC)r/  r-  r	  r
  r.  r   r  )Nr   r   N)r0  r   r  r   r   )r8  z
int | Noner$  )r'  str | bytes)r'  r  r   None)r'  zstr | bytes | Nonern  r   )r   r  )r   TF)r   r   r   r   r#  )r   r   r   r  r%  r   r  r   r  r;  r   r   ra  re  rh  rk  r6   ro  ru  rx  r~  r  r  r  r  r   r   r+  r+    s    , ! ! 	!F ) ) ( ( D?QBtl+Z6,. AN C:& @8D,\ ./a = =r   r+  c                D    U R                   (       a  [        [        5      eg)z<raise ENOTSUP if socket is closed

Does not do a deep check
N)r/  ry   r&   )ss    r   r>  r>  3  s     	yyx   r   c           
     d   [        [        R                  5      n[        [        5      nU R                  (       a  g[        U R                  [        [        [        [        U5      5      [        U5      5      nUS:  a)  [        5       nU[        :X  a  SU l        gU[        :X  a  g g[        U5        g)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   rM  r{   r   r/  rP   r  rA   r   r   r   r   r&   r5   r   )r  styper   r   r   s        r   r5  r5  >  s     AEENEByyHHhVWU^ <gbk
 6LE  	)# $
  bMr   c                    [         R                  " US9nUn [           [        [	        UR
                  5      X5      nSSS5         [        W5         U$ ! , (       d  f       N= f! [         a     M\  f = f)z=Receive a message in a non-copying manner and return a Frame.)r   N)r   r   r   r]   r   r   r   rx   )r  r   r   r   cmsgr   s         r   r  r  `  sh    
 ))%
 CD
gdll3VCB 	bM J U % 		s    AA& 
A#&
A43A4c                R   [        [        5      n[        U5      n[        U5      n[	        U5         [
           [        X0U5      nSSS5         [	        U5         [        U5      n[        U5        U$ ! , (       d  f       N3= f! [         a     M_  [         a    [        U5        e f = f)z#Receive a message and return a copyN)r   rd   r   rZ   r   r   r]   rx   	ExceptionrT   r   )r  r   r   	zmq_msg_pr   	msg_bytess         r   r  r  t  s     i G$+G$4IY'BbM
i7B 	bM #I.I) U % 	 	)$	s   A2B 2
B 
B&B&c                    UR                  5       n [           [        [        UR                  5      X5      nSSS5         [        W5         UR                  $ ! , (       d  f       N'= f! [         a     Mf  f = f)z1Send a Frame on this socket in a non-copy manner.N)r   r   r_   r   r   r   rx   r   )r  r   r   msg_copyr   s        r   r}  r}    sg     }}H
gh&6&67GB 	bM ;; U % 		s    AA* 
A'*
A87A8c           
     ,   [        [        5      n[        [        5      n[        U[	        U5      5      n[        [	        U5      U5      n[        U5         [           [        [        [	        U5      5      U[        [	        U5      5      5        [        [	        U5      X5      nSSS5         [        U5        [        [	        U5      5      n[        U5        g! , (       d  f       N:= f! [         a     M  [         a    [        [	        U5      5        e f = f)z5Send a message on this socket by copying its content.N)r   rd   r   r   r   r\   r   r   r,   rV   rc   r_   rT   rx   r  )r  r   r   r   c_bytesc_bytes_lenr   s          r   r{  r{    s    
 )
CfoG C!12K
 
73<	5BbM
<-wWS\8RSgclF:B 
	bM ws|,BbM U
 % 	 	'#,'	s   AC+C' 
C$'
D4Dc                \    Sn [        XX#5      n [        U5        g! [         a     M'  f = f)zPgetsockopt, retrying interrupted calls

checks rc, raising ZMQError on failure.
r   N)rP   r   rx   r  r   r  r   r   s        r   rN  rN    =     B
FF7	bM  % 		    
++c                \    Sn [        XX#5      n [        U5        g! [         a     M'  f = f)zPsetsockopt, retrying interrupted calls

checks rc, raising ZMQError on failure.
r   N)rm   r   rx   r  s        r   r@  r@    r  r  c                     [        5       $ )z6Return the integer errno of the most recent zmq error.)r   r  r   r   rr   rr     s
    <r   c                <    [        U 5      nUR                  SS5      $ )z1
Return the error string given the error number.
r   replace)rp   r   )r   str_es     r   strerrorr    s      &E<<	**r   c                 f    Sn SnSn[        [        U 5      [        U5      [        U5      5        XU4$ )z9Return the version of ZeroMQ itself as a 3-tuple of ints.r   )rB   r   )majorminorpatchs      r   zmq_version_infor    s4    EEE@%  r   c                d    [        SS5        U R                  S5      n[        [        U5      5      $ )zlCheck for zmq capability by name (e.g. 'ipc', 'curve')

.. versionadded:: libzmq-4.1
.. versionadded:: 14.1
r   zzmq.hasr   )rz   r   r}   rQ   )
capabilityccaps     r   hasr    s-     69%##F+Dr   c                     [        [        S   5      n [        [        S   5      n[        SS5        [        X5      n[	        U5        X4$ )uJ  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   rz   rL   r   )
public_key
secret_keyr   s      r   r  r    sF      b"Jb"J6?+ 
:	2BbM!!r   c                    [        U [        5      (       a  U R                  S5      n [        U 5      S:X  d  [	        S5      e[        [        S   5      nU n[        SS5        [        X5      n[        U5        USS $ )u<  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  rr  curve_publicN)
r   r   r   r   r   r   r   rz   rM   r   )r  r  c_secret_keyr   s       r   r  r  *  sw      *c""&&v.
z?b JKK b"J",L6>* 
*	3BbMcr?r   c           	        [         n[        U 5      nUS:X  a  / $ [        [        [        5      [        U[        [        5      -  5      5      nU[         :X  a  [        S5      e[        U5       GH
  nX   u  pV[        U[        5      (       a>  [        [        U5      R                  X$   l        SX$   l        XbU   l        SX$   l        M]  [        U[         5      (       a,  Un[         X$   l        XrU   l        XbU   l        SX$   l        M  [#        US5      (       aD   [!        UR%                  5       5      n[         X$   l        XrU   l        XbU   l        SX$   l        M  [)        U5        [-        SU< 35      e   Sn  [/        5       n	[0           [3        X#U5      n
SSS5         [5        W
5         / n[        U5       HW  nX$   R                  nUS:  d  M  X$   R                  [         :w  a  X   S   nOX$   R                  nURA                  X]45        MY     [)        U5        U$ ! [&         a    [)        U5        [+        S5      ef = f! , (       d  f       N= f! [6         aZ    US:  aO  [/        5       n[!        SX-
  -  5      nUS:  a!  [8        R:                  " SU S	3[<        5        Sn[?        SX-
  5      n GM@  f = f! [&         a    [)        U5        e f = f)
a5  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: Ni  z,Negative elapsed time for interrupted poll: z.  Did the clock change?)!r	   r   r   r   ri   r+   r   MemoryErrorranger   r+  r  socketrO  rn  reventsr{   hasattrr  r  r*   r   r   r   r   
zmq_poll_cr   rx   rS  rT  RuntimeWarningmaxappend)socketstimeout	pollitemsnsocketsir  rn  r  	ms_passedstartr   ticresultsr  s                 r   rs   rs   K  s   ( *.I'lH1}	W^,fX~@V5V.WXID9::8_J	a  "&vq/"8"8ILILO"(aL#$IL 3F"&IL$aLO"(aL#$IL Q!!	)QXXZ
 '+	#"(!&,!#'(	$O&&'U, 5 > I$;E	W= "& 
 G8_,&& Q;|""d*JqMLOONNA<(  	ON{  LY !JKKL(  ) Q;#+C #DCK$8 9I 1} !J9+ V6 6* %&	!!W%89G!&  YsO   H&>K I
K %I &!I

IK AJ?:K >J??K Kc                   Sn[        U[        5      (       a  UR                  nO[        n [           [        U R                  UR                  U5      nSSS5         [        U5         U$ ! , (       d  f       N= f! [         a     M^  f = f)aN  
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   N)r   r+  r  r	   r   rj   r   rx   )frontendbackendcapturer   capture_handles        r   proxyr    sv      B'6"" 
8??GNNNKB 	bM I U % 		s   "A+A< +
A9<
B
	B
c                j   Sn[        U[        5      (       a  UR                  nO[        n[        U[        5      (       a  UR                  nO[        n [           [        U R                  UR                  XV5      nSSS5         [        U5         U$ ! , (       d  f       N= f! [         a     M^  f = f)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   N)r   r+  r  r	   r   rk   r   rx   )r  r  r  controlr   r  control_handles          r   proxy_steerabler    s    . B'6"" '6"" 
$B 	bM I U % 		s   "BB$ 
B!$
B21B2c                   [        [        5      n[        [        5      n[        [        5      nU(       Ga  [	        [        U5      U S5      n	U	S:  a  U	$ [	        [        U5      U S5      n	U	S:  a  U	$ [        [        U5      [        U5      5      n	U	S:  a  U	$ [        [        U5      U[        5      n	U	S:  a  U	$ [        [        U5      U[        5      n	U	S:  a  U	$ [        [        U5      [        U5      5      n	U	S:  a  U	$ [        [        U5      U[        5      n	U	S:  a  U	$ [        [        U5      U[        5      n	U	S:  a  U	$  [	        [        U5      U S5      n	U	S:  a  U	$ [        U [        [        U5      [        U5      5      n	U	S:  a  U	$ Sn
U(       a	  U
[        -  n
[        [        U5      [        U5      5      n	U	S:  a  U	$ U
(       a@  [        [        U5      X5      n	U	S:  a  U	$ [        [        U5      U[        5      n	U	S:  a  U	$ O?[        [        U5      US5      n	U	S:  a  U	$ [        [        U5      US5      n	U	S:  a  U	$  U	$ GM  r  )r   r   r{   r   r]   r   rU   r_   r?   rP   r=   )	in_socket
out_socketside_socketr   side_msgid_msgswap_idsflagszr   r   r   s              r   	_mq_relayr    s#    V_F3<DC[F'#,	156I'&/9a86I '(+WV_=6I'(+ZE6I'&/;D6I'(+WS\:6I'(+ZE6I'#,[A6I
'#,	156II{GDM76?S6I[ E'(+WS\:6Igh/CBAv	gclKEBAv	  gh/Q?BAv	gclK;BAv	I? r   c           	        [        [        5      n[        [        U5      5      n[        [        5      n[        [        U5      5      nUS:  a  U$ [        [        5      n	[        [        U	5      5      nUS:  a  U$ [        [        S   5      n
X
S   l        [        U
S   l        S=U
S   l        U
S   l	        XS   l        [        U
S   l        S=U
S   l        U
S   l	         [        [        U
S   5      SS5      nUS:  a  U$ U
S   R                  [        -  (       aU  [        [        U	5      U5      nUS:  a  U$ [        [        U	5      U[        5      nUS:  a  U$ [        XX&XU5      nUS:  a  U$ U
S   R                  [        -  (       aU  [        [        U	5      U5      nUS:  a  U$ [        [        U	5      U[        5      nUS:  a  U$ [        XX&XU5      nUS:  a  U$ GM  )z&
inner C function for monitored_queue
r   rJ  r   r   )r   rd   rZ   r   ri   r  r;   rn  rO  r  r  rU   r_   r?   r  )r  r  r  
in_msg_ptrout_msg_ptrr  r   r   r  r  itemss              r   
_mq_inliner  _  s    Y'CWS\*BYF	gfo	&B	Av	y!H	gh'	(B	Av	N1%&E!HO E!HO%&&E!HK%(" !HO E!HO%&&E!HK%("
a)1b16I8j(gh/<BAv	gh/kJBAv	{8B Av	8j(gh/=BAv	gh/kJBAv	{8B Av	A r   c           
     f   U R                   nUR                   nUR                   n[        [        5      n[        [        5      n	[        n
[        [        5      nU R
                  [        :H  =(       a    UR
                  [        :H  n[        U[        U
5      5      n[        [        U5      U5      n[        U5        [        [        [        U5      5      U
[        [        U5      5      5        [        U[        U
5      5      n[        [        U	5      U5      n[        U5         [           [        [        [        U	5      5      U
[        [        U	5      5      5        [        XVU[        U5      [        U	5      U5      nSSS5         [        U5         U$ ! , (       d  f       N= f! [          a     M  f = f)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.
N)r  r   rd   r	   r
   typer>   r   r   r\   r   r,   rV   rc   r   r  rx   )r  r  
mon_socket	in_prefix
out_prefixinsoutsmonsin_msgout_msgmsg_c	msg_c_lenr  r   s                 r   monitored_queuer    sU   D ""C$$D$$DYFi GE
#I ~~+M
:0MH )WU^4I	76?I	6BbM
<(%gfo1NO*gen5I	77+Y	7BbM
WW-.|GGDT7U 4''2BHB	 	bM I U % 		s   'AFF" 
F"
F0/F0)r|   r~   r  r+  r   r  r  r  r  rr   rs   r  r  r  )F)r   r   r   r   r   r   )r   r   r   r   r   r   )r   pointer(zmq_msg_t)r   r   )r   zpointer(p_void)r   r   r   r   )r   r   )r  r+  )r  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   zpointer(size_t))r  r   r   r   r  r   r   r   r#  )r   r   r   r   )r   ztuple[int, int, int])r  r   r   r}   )r   ztuple[bytes, bytes])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   rd   r  rd   r  rd   r  r   r   r   )r  r   r  r   r  r   r  r  r  r  r  r   r   r   )s   ins   out)
r  r+  r  r+  r  r+  r  r   r  r   )r%  
__future__r   cythoncompiledImportErrorpathlibr   __file__parentszmq_rootr   rS  	threadingr   timer   weakrefr   rM  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.cythonr-   +cython.cimports.zmq.backend.cython._externsr.   r/   r0   r1   r2   r3   )cython.cimports.zmq.backend.cython.libzmqr4   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   rr   r   rs   r  r   zmq.constantsrt   ru   	zmq.errorrv   rw   rx   ry   rz   r|   __annotations__r}   r~   	exceptvalr   structr   r   r   r   r   r   r  r)  r+  r>  r5  r  r  r}  r{  rN  r@  r  r  r  r  r  r  r  r  r  r  __all__r  r   r   <module>r     s   
 #??m .         $  
 ; T T 0 . 8 4 . 5 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?@ N L 
 0  -. # .V334 4 R   . 
	
'

 (  (V 9  9       D @ @ @F    }	 }	 }	F !  !   @   $   0   ,   @       &
+!"4Bk\J 	,,, , 	,b MMM M 
	M
 M M M M   M` @@@ @ #	@
 $@ @ @   @N III I 	I
 IXE?  H~%%a(H "
 #!
 #C c
's   M 3N