
    h                       % S r SSKJr  SSKrSSKrSSK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  SSKJr  SSKrSSKJr  SSKJr  SSKJrJr  SS	KJr  SS
KJ r   SSK!J"r"J#r#J$r$  SSK%J&r&  SSK'J(r(   \RR                  r)\" SSS9r,Sr-S\.S'    " S S\
\,   5      r/\" S5      r0 " S S\\&\
\0   5      r\\1   r2S\.S'   SS/r3g! \* a    \RV                  r) NWf = f)z0MQ Socket pure Python methods.    )annotationsN)
AnyCallableGenericListLiteralSequenceTypeVarUnioncastoverload)warn)	TypeAlias)Socket)ZMQBindErrorZMQError)jsonapi)cast_int_addr   )SocketOption
SocketType_OptType   )AttributeSetter)Poller_SocketTyper   )boundz9int | str | bool | list[_JSONType] | dict[str, _JSONType]r   	_JSONTypec                  h    \ rS rSr% SrS\S'   S\S'   S\S'   S r        SS	 jrSS
 jrS r	Sr
g)_SocketContext/   z&Context Manager for socket bind/unbindr   socketstrkindaddrc                >    SU R                    SU R                  < S3$ )Nz<SocketContext(=z)>)r$   r%   selfs    cC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\zmq/sugar/socket.py__repr___SocketContext.__repr__6   s     1TYYM<<    c                8    US;   d   eXl         X l        X0l        g )N>   bindconnect)r"   r$   r%   )r)   r"   r$   r%   s       r*   __init___SocketContext.__init__9   s"     ****		r-   c                    U R                   $ N)r"   r(   s    r*   	__enter___SocketContext.__enter__A   s    {{r-   c                   U R                   R                  (       a  g U R                  S:X  a&  U R                   R                  U R                  5        g U R                  S:X  a&  U R                   R                  U R                  5        g g )Nr/   r0   )r"   closedr$   unbindr%   
disconnect)r)   argss     r*   __exit___SocketContext.__exit__D   s[    ;;99KKtyy)YY)#KK""499- $r-   )r%   r$   r"   N)r)   _SocketContext[_SocketType]r"   r   r$   r#   r%   r#   )r)   r>   returnr   )__name__
__module____qualname____firstlineno____doc____annotations__r+   r1   r5   r<   __static_attributes__ r-   r*   r    r    /   sI    0
I
I=)3>FIQT.r-   r    SocketReturnTypec                  l  ^  \ rS rSrSrSrSrSrSr\	SS.       SAS jj5       r
\	SS.     SBS jj5       r
\	    SCS	 j5       r
  SDS
SS.         SEU 4S jjjjr
S rSrS rSFS jrS rSGSFS jjr\r\SHS j5       rSGSIU 4S jjjrSJS jrSJS jrSJU 4S jjrSJU 4S jjr\SKS j5       rS r\R:                  r\R>                  r U 4S jr!SKS jr"SLS jr#SLS jr$SMSNS jjr%\%=r&r'SMSOS  jjr(\(=r)r*   SP           SQS! jjr+SKS" jr,SRS# jr-\" \,\-SS$5      r.\	  SSS%S%S&.             STS' jjj5       r/\	  SSS%S%S&.             SUS( jjj5       r/\	 SVS%S%S%S).           SWS* jjj5       r/\	     SX             SYS+ jj5       r/     SZ             SYU 4S, jjjr/   S[       S\S- jjr0\	 SVS%S..       S]S/ jjj5       r1\	 SVS%S..       S^S0 jjj5       r1\	SVS%S..S_S1 jjj5       r1\	 S[       S`S2 jj5       r1 S[       S`S3 jjr1      SaS4 jr2SbS5 jr3SbS6 jr4   Sc         SdS7 jjr5\5r6SeSfS8 jjr7\7r8S
\94       SgS9 jjr:ShSiS: jjr;ShSjS; jjr<ShSkS< jjr=\>r?S\@R                  4SlS= jjrB Sm       SnS> jjrCSIS? jrDS@rEU =rF$ )or   P   a  The ZMQ socket object

To create a Socket, first create a Context::

    ctx = zmq.Context.instance()

then call ``ctx.socket(socket_type)``::

    s = ctx.socket(zmq.ROUTER)

.. versionadded:: 25

    Sockets can now be shadowed by passing another Socket.
    This helps in creating an async copy of a sync socket or vice versa::

        s = zmq.Socket(async_socket)

    Which previously had to be::

        s = zmq.Socket.shadow(async_socket.underlying)
FNUNKNOWN)copy_thresholdc                   g r4   rG   )r)   ctx_or_socketsocket_typerL   s       r*   r1   Socket.__init__l   s     r-   c                   g r4   rG   )r)   shadowrL   s      r*   r1   rP   u   s     r-   c                    g r4   rG   )r)   rN   s     r*   r1   rP   }   s     r-   r   rR   rL   c                 > S n[        U[        R                  5      (       a  UnS nSnU(       at  SU l        X0l        [        U[
        5      (       dF  [        U[        R                  5      (       a  UR                  n [        [
        UR                  5      n[        U5      nOSU l        [        TU ]1  UUUUS9  U R                  (       a  U(       a  XPl         [        [
        U R                  [        R                  5      5      n [        U5      =U R                   S'   nUR"                  U l        g ! [         a     Nf = f! [&         a    [)        U5      U l         g f = f! [*         a     g f = f)Nr   TFrT   type)
isinstancezmqr   _shadow_shadow_objintcontextr   
underlyingAttributeErrorr   superr1   getTYPEr   __dict__name
_type_name
ValueErrorr#   	Exception)	r)   rN   rO   rR   rL   shadow_contextshadow_addressstype	__class__s	           r*   r1   rP      sF    .2mSZZ00"F MDL%fc**fcjj11%+^^N!#v'8'89F +62N DL!)	 	 	
 )L
	-sDHHSXX$67K-0:;0GGf% #(**5 & .  3"%k"23  		s6   >D4 -E$ E 4
E EE! E!$
E10E1c                    U R                   (       d=  U R                  (       d+  [        b  [        SU  3[        SU S9  U R	                  5         g g g )NzUnclosed socket r   )
stacklevelsource)rY   r8   r   ResourceWarningcloser(   s    r*   __del__Socket.__del__   sB    ||DKK&tf-# 	 JJL %0|r-   z
zmq.Socketc           
        U R                   nUR                  R                  SS 5      nUc  UR                   SUR                   3nU R
                  (       a  SOSnSU SU R                   S[        [        U 5      5       U S3$ )	N	_repr_cls.z closed <z(zmq.z) at >)	rj   rb   r`   rA   r@   _closedrd   hexid)r)   clsrs   r8   s       r*   r+   Socket.__repr__   sy    nnLL$$[$7	>>*!CLL>:I"ll9+U4??"35RXxqQQr-   c                    U $ )z5Sockets are context managers

.. versionadded:: 14.4
rG   r(   s    r*   r5   Socket.__enter__   s	    
 r-   c                $    U R                  5         g r4   )ro   )r)   r;   kwargss      r*   r<   Socket.__exit__   s    

r-   c                L    U R                   R                  U R                  5      $ )z&Copying a Socket creates a shadow copy)rj   rR   r]   )r)   memos     r*   __copy__Socket.__copy__   s    ~~$$T__55r-   c                    U " US9$ )a  Shadow an existing libzmq socket

address is a zmq.Socket or an integer (or FFI pointer)
representing the address of the libzmq socket.

.. versionadded:: 14.1

.. versionadded:: 25
    Support for shadowing `zmq.Socket` objects,
    instead of just integer addresses.
)rR   rG   )r{   addresss     r*   rR   Socket.shadow   s     '""r-   c                x   > U R                   (       a  U R                   R                  U 5        [        TU ]  US9  g)a'  
Close the socket.

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

Note: closing a zmq Socket may not close the underlying sockets
if there are undelivered messages.
Only after all messages are delivered or discarded by reaching the socket's LINGER timeout
(default: forever)
will the underlying sockets be closed.

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,
in which case you may see a ResourceWarning about the unclosed socket.
)lingerN)r\   
_rm_socketr_   ro   )r)   r   rj   s     r*   ro   Socket.close   s,    " <<LL##D)V$r-   c                    [        U SU5      $ )z>Context manager to disconnect on exit

.. versionadded:: 20.0
r0   )r    r)   r%   s     r*   _connect_cmSocket._connect_cm  s    
 dIt44r-   c                     [        [        U R                  [        R                  5      5      R                  S5      n[        U SU5      $ ! [        [        [        4 a     N$f = f)z:Context manager to unbind on exit

.. versionadded:: 20.0
utf8r/   )
r   bytesr`   rX   LAST_ENDPOINTdecoder^   r   UnicodeDecodeErrorr    r   s     r*   _bind_cmSocket._bind_cm  s\    
	 txx(9(9:;BB6JD dFD11 *<= 		s   <A A#"A#c                   >  [         TU ]  U5        U R	                  U5      $ ! [         a   nU=R                  SU< S3-  sl        e SnAff = f)a  s.bind(addr)

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.

Returns a context manager which will call unbind on exit.

.. versionadded:: 20.0
    Can be used as a context manager.

.. versionadded:: 26.0
    binding to port 0 can be used as a context manager
    for binding to a random port.
    The URL can be retrieved as `socket.last_endpoint`.

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.

 (addr=)N)r_   r/   r   strerrorr   r)   r%   erj   s      r*   r/   Socket.bind#  sQ    8	GL }}T""  	JJGD81--J	   # 
AAAc                   >  [         TU ]  U5        U R	                  U5      $ ! [         a   nU=R                  SU< S3-  sl        e SnAff = f)a  s.connect(addr)

Connect to a remote 0MQ socket.

Returns a context manager which will call disconnect on exit.

.. versionadded:: 20.0
    Can be used as a context manager.

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   r   N)r_   r0   r   r   r   r   s      r*   r0   Socket.connectF  sS    &	GOD! %%  	JJGD81--J	r   c                V    [        S[        5        [        [        U R                  5      $ )Nz1Socket.socket_type is deprecated, use Socket.type)r   DeprecationWarningr   r[   rV   r(   s    r*   rO   Socket.socket_typed  s    @BTUC##r-   c                n    [        U R                  5      nUR                  [        R                  5        U$ r4   )dirrj   extendr   __members__)r)   keyss     r*   __dir__Socket.__dir__m  s'    4>>"L,,-r-   c                x  > XR                   ;   a  [        R                  XU5        gUR                  5       nUS;   an  [	        U[
        5      (       a  UR                  S5      nUS:X  a!  U R                  [        R                  U5        gU R                  [        R                  U5        g[        TU ]	  X5        g)zROverride to allow setting zmq.[UN]SUBSCRIBE even though we have a subscribe methodN)	subscribeunsubscriber   r   )rb   object__setattr__lowerrW   r#   encodesetrX   	SUBSCRIBEUNSUBSCRIBEr_   )r)   keyvalue_keyrj   s       r*   r   Socket.__setattr__x  s    --t%0yy{//%%%V,{".  %0C'r-   c                    U R                   $ )a4  Return edge-triggered file descriptor for this socket.

This is a read-only edge-triggered file descriptor for both read and write events on this socket.
It is important that all available events be consumed when an event is detected,
otherwise the read event will not trigger again.

.. versionadded:: 17.0
)FDr(   s    r*   filenoSocket.fileno  s     wwr-   c                    [        U[        5      (       a  UR                  S5      nU R                  [        R
                  U5        g)zDSubscribe to a topic

Only for SUB sockets.

.. versionadded:: 15.3
r   N)rW   r#   r   r   rX   r   r)   topics     r*   r   Socket.subscribe  s1     eS!!LL(E&r-   c                    [        U[        5      (       a  UR                  S5      nU R                  [        R
                  U5        g)zHUnsubscribe from a topic

Only for SUB sockets.

.. versionadded:: 15.3
r   N)rW   r#   r   r   rX   r   r   s     r*   r   Socket.unsubscribe  s1     eS!!LL(E%(r-   c                    [        U[        5      (       d  [        S[        U5       SU< 35      eU R	                  XR                  U5      5      $ )a  Set socket options with a unicode object.

This is simply a wrapper for setsockopt to protect from encoding ambiguity.

See the 0MQ documentation for details on specific options.

Parameters
----------
option : int
    The name of the option to set. Can be any of: SUBSCRIBE,
    UNSUBSCRIBE, IDENTITY
optval : str
    The value of the option to set.
encoding : str
    The encoding to be used, default is utf8
zstrings only, not z: )rW   r#   	TypeErrorrV   r   r   )r)   optionoptvalencodings       r*   
set_stringSocket.set_string  sF    " &#&&0fb
KLLxxh 788r-   c                    [        U5      R                  [        R                  :w  a  [	        SU S35      e[        [        U R                  U5      5      R                  U5      $ )zGet the value of a socket option.

See the 0MQ documentation for details on specific options.

Parameters
----------
option : int
    The option to retrieve.

Returns
-------
optval : str
    The value of the option as a unicode string.
zoption z' will not return a string to be decoded)r   	_opt_typer   r   r   r   r`   r   )r)   r   r   s      r*   
get_stringSocket.get_string  sQ     ))X^^;gfX-TUVVE488F+,33H==r-   c                :   US:X  ac  US:X  a]  U R                  U S35        [        [        U R                  5      R	                  SS5      nUR                  SS5      u  pg[        U5      $ [        U5       H2  n [        R                  " X#5      n	U R                  U SU	 35        U	s  $    [#        S
5      e! [         aZ  n
U
R                  nU[        R                  :X  a   Sn
A
Mq  [        R                  S	:X  a  U[        R                   :X  a   Sn
A
M  e Sn
A
ff = f)ae  Bind this socket to a random port in a range.

If the port range is unspecified, the system will choose the port.

Parameters
----------
addr : str
    The address string without the port to pass to ``Socket.bind()``.
min_port : int, optional
    The minimum port in the range of ports to try (inclusive).
max_port : int, optional
    The maximum port in the range of ports to try (exclusive).
max_tries : int, optional
    The maximum number of bind attempts to make.

Returns
-------
port : int
    The port the socket was bound to.

Raises
------
ZMQBindError
    if `max_tries` reached before successful bind
      z:*asciireplace:r   Nwin32z%Could not bind socket to random port.)r/   r   r   last_endpointr   rsplitr[   rangerandom	randranger   errnorX   
EADDRINUSEsysplatformEACCESr   )r)   r%   min_portmax_port	max_triesurl_port_siport	exceptionens               r*   bind_to_random_portSocket.bind_to_random_port  s    @ uU!2 IIbk"ud00188)LC

3*IAv;y!A'';		TF!D6*+  " BCC  __'\\W,u||1Cs$   9,B66
D  D&(DDDc                     [        [        U R                  [        R                  5      5      $ ! [        R
                   a     Of = f[        [        U R                  [        R                  5      5      $ )u[   Get the High Water Mark.

On libzmq ≥ 3, this gets SNDHWM if available, otherwise RCVHWM
)r   r[   r`   rX   SNDHWMr   RCVHWMr(   s    r*   get_hwmSocket.get_hwm  sS    	TXXcjj122|| 		 C#**-..s   ,/ AAc                    Sn Xl          Xl        U(       a  Ueg! [         a  nUn SnAN"SnAff = f! [         a  nUn SnAN4SnAff = f)u   Set the High Water Mark.

On libzmq ≥ 3, this sets both SNDHWM and RCVHWM


.. warning::

    New values only take effect for subsequent socket
    bind/connects.
N)sndhwmrf   rcvhwm)r)   r   raisedr   s       r*   set_hwmSocket.set_hwm  sY     	K	K L   	F	  	F	s$    4 
1,1
A
AA
zProperty for High Water Mark.

        Setting hwm sets both SNDHWM and RCVHWM as appropriate.
        It gets SNDHWM if available, otherwise RCVHWM.
        .
routing_idgroupc                   g r4   rG   r)   dataflagscopytrackr   r   s          r*   sendSocket.sendA  s     !r-   c                   g r4   rG   r   s          r*   r  r  M  s     r-   )r   r   r   c                   g r4   rG   )r)   r   r   r   r   r   s         r*   r  r  Y  s     r-   c                    g r4   rG   r   s          r*   r  r  d  s     %(r-   c                h  > UbO  [        U[        R                  5      (       d*  [        R                  " UUU=(       d    SU R                  S9nXQl        UbO  [        U[        R                  5      (       d*  [        R                  " UUU=(       d    SU R                  S9nXal        [        TU ]  XX4S9$ )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 (i.e. `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)
routing_id : int
    For use with SERVER sockets
group : str
    For use with RADIO sockets

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
    If the send does not succeed for any reason (including
    if NOBLOCK is set and the outgoing queue is full).


.. versionchanged:: 17.0

    DRAFT support for routing_id and group arguments.
N)r   r   rL   )r   r   r   )rW   rX   FramerL   r   r   r_   r  )r)   r   r   r   r   r   r   rj   s          r*   r  r  o  s    r !dCII..yy#'#6#6	 )OdCII..yy#'#6#6	 Jw|DD|FFr-   c           	        [        U5       H=  u  pg[        U[        R                  [        [
        45      (       a  M1   [        U5        M?     USS  H%  nU R                  U[        R                  U-  X4S9  M'     U R                  US   X#US9$ ! [         a5    [        U5      n[        U5      S:  a  USS S-   n[        SU SU S35      ef = f)	a  Send a sequence of buffers as a multipart message.

The zmq.SNDMORE flag is added to all msg parts before the last.

Parameters
----------
msg_parts : iterable
    A sequence of objects to send as a multipart message. Each element
    can be any sendable object (Frame, bytes, buffer-providers)
flags : int, optional
    Any valid flags for :func:`Socket.send`.
    SNDMORE is added automatically for frames before the last.
copy : bool, optional
    Should the frame(s) be sent in a copying or non-copying manner.
    If copy=False, frames smaller than self.copy_threshold bytes
    will be copied anyway.
track : bool, optional
    Should the frame(s) be tracked for notification that ZMQ has
    finished with it (ignored if copy=True).

Returns
-------
None : if copy or not track
MessageTracker : if track and not copy
    a MessageTracker object, whose `done` property will
    be False until the last send is completed.
    Nz...zFrame z (z() does not support the buffer interface.r   r   )	enumeraterW   rX   r  r   
memoryviewrf   reprlenr   r  SNDMORE)	r)   	msg_partsr   r   r   r   r   msgrmsgs	            r*   send_multipartSocket.send_multipart  s    H  	*FA#		5*=>>3	 + Sb>CIIc3;;.TIG " yy2yFF  Cyt9r>9u,DQCr$'OP 	s   B?C)r   c                   g r4   rG   r)   r   r   r   s       r*   recv_multipartSocket.recv_multipart  s     r-   c                   g r4   rG   r  s       r*   r  r    s     r-   c                   g r4   rG   )r)   r   r   s      r*   r  r    s    UXr-   c                    g r4   rG   r  s       r*   r  r    s     ),r-   c                d   U R                  XUS9/nU R                  [        R                  5      (       aG  U R                  XUS9nUR	                  U5        U R                  [        R                  5      (       a  MG  [        [        [        [        R                     [        [           4   U5      $ )a  Receive a multipart message as a list of bytes or Frame objects

Parameters
----------
flags : int, optional
    Any valid flags for :func:`Socket.recv`.
copy : bool, optional
    Should the message frame(s) be received in a copying or non-copying manner?
    If False a Frame object is returned for each part, if True a copy of
    the bytes is made for each frame.
track : bool, optional
    Should the message frame(s) be tracked for notification that ZMQ has
    finished with it? (ignored if copy=True)

Returns
-------
msg_parts : list
    A list of frames in the multipart message; either Frames or bytes,
    depending on `copy`.

Raises
------
ZMQError
    for any of the reasons :func:`~Socket.recv` might fail
r  )
recv
getsockoptrX   RCVMOREappendr   r   r   r  r   )r)   r   r   r   partsparts         r*   r  r    s    8 559:oockk**99UU9;DLL oockk**
 E$syy/4;67??r-   c                    U" U5      $ )a8  Deserialize a received message

Override in subclass (e.g. Futures) if recvd is not the raw bytes.

The default implementation expects bytes and returns the deserialized message immediately.

Parameters
----------

load: callable
    Callable that deserializes bytes
recvd:
    The object returned by self.recv

rG   )r)   recvdloads      r*   _deserializeSocket._deserialize(  s    ( E{r-   c                <    U" U5      nU R                   " U4X4S.UD6$ )a  Send a message with a custom serialization function.

.. versionadded:: 17

Parameters
----------
msg : The message to be sent. Can be any object serializable by `serialize`.
serialize : callable
    The serialization function to use.
    serialize(msg) should return an iterable of sendable message frames
    (e.g. bytes objects), which will be passed to send_multipart.
flags : int, optional
    Any valid flags for :func:`Socket.send`.
copy : bool, optional
    Whether to copy the frames.

r   r   )r  )r)   r  	serializer   r   r   framess          r*   send_serializedSocket.send_serialized>  s(    $ 3""6LLVLLr-   c                B    U R                  X#S9nU R                  XA5      $ )aW  Receive a message with a custom deserialization function.

.. versionadded:: 17

Parameters
----------
deserialize : callable
    The deserialization function to use.
    deserialize will be called with one argument: the list of frames
    returned by recv_multipart() and can return any object.
flags : int, optional
    Any valid flags for :func:`Socket.recv`.
copy : bool, optional
    Whether to recv bytes or Frame objects.

Returns
-------
obj : object
    The object returned by the deserialization function.

Raises
------
ZMQError
    for any of the reasons :func:`~Socket.recv` might fail
r*  )r  r'  )r)   deserializer   r   r,  s        r*   recv_serializedSocket.recv_serializedS  s(    4 $$5$<  55r-   c                    [        U[        5      (       d  [        S5      eU R                  " UR	                  U5      4X#S.UD6$ )a<  Send a Python unicode string as a message with an encoding.

0MQ communicates with raw bytes, so you must encode/decode
text (str) around 0MQ.

Parameters
----------
u : str
    The unicode string to send.
flags : int, optional
    Any valid flags for :func:`Socket.send`.
encoding : str
    The encoding to be used
zstr objects onlyr*  )rW   r#   r   r  r   )r)   ur   r   r   r   s         r*   send_stringSocket.send_stringp  s?    , !S!!.//yy(+N5NvNNr-   c                N   ^ U R                  US9nU R                  UU4S j5      $ )aU  Receive a unicode string, as sent by send_string.

Parameters
----------
flags : int
    Any valid flags for :func:`Socket.recv`.
encoding : str
    The encoding to be used

Returns
-------
s : str
    The Python unicode string that arrives as encoded bytes.

Raises
------
ZMQError
    for any of the reasons :func:`Socket.recv` might fail
)r   c                &   > U R                  T5      $ r4   )r   )bufr   s    r*   <lambda>$Socket.recv_string.<locals>.<lambda>  s    #**X2Fr-   r  r'  )r)   r   r   r  s     ` r*   recv_stringSocket.recv_string  s)    ( iiei$  &FGGr-   c                X    [         R                  " X5      nU R                  " U4SU0UD6$ )a  
Send a Python object as a message using pickle to serialize.

.. warning::

    Never deserialize an untrusted message with pickle,
    which can involve arbitrary code execution.
    Make sure to authenticate the sources of messages
    before unpickling them, e.g. with transport-level security
    (e.g. CURVE, ZAP, or IPC permissions)
    or signed messages.

Parameters
----------
obj : Python object
    The Python object to send.
flags : int
    Any valid flags for :func:`Socket.send`.
protocol : int
    The pickle protocol number to use. The default is pickle.DEFAULT_PROTOCOL
    where defined, and pickle.HIGHEST_PROTOCOL elsewhere.
r   )pickledumpsr  )r)   objr   protocolr   r  s         r*   
send_pyobjSocket.send_pyobj  s+    2 ll3)yy4E4V44r-   c                d    U R                  U5      nU R                  U[        R                  5      $ )a  
Receive a Python object as a message using UNSAFE pickle to serialize.

.. warning::

    Never deserialize an untrusted message with pickle,
    which can involve arbitrary code execution.
    Make sure to authenticate the sources of messages
    before unpickling them, e.g. with transport-level security
    (such as CURVE or IPC permissions)
    or authenticating messages themselves before deserializing.

Parameters
----------
flags : int
    Any valid flags for :func:`Socket.recv`.

Returns
-------
obj : Python object
    The Python object that arrives as a message.

Raises
------
ZMQError
    for any of the reasons :func:`~Socket.recv` might fail
)r  r'  r@  loads)r)   r   r  s      r*   
recv_pyobjSocket.recv_pyobj  s)    8 ii  fll33r-   c                    0 nS H  nXS;   d  M
  UR                  U5      XE'   M     [        R                  " U40 UD6nU R                  " U4SU0UD6$ )zSend a Python object as a message using json to serialize.

Keyword arguments are passed on to json.dumps

Parameters
----------
obj : Python object
    The Python object to send
flags : int
    Any valid flags for :func:`Socket.send`
r   r   )popr   rA  r  )r)   rB  r   r   send_kwargsr   r  s          r*   	send_jsonSocket.send_json  sV     *C}#)::c?  + mmC*6*yy9E9[99r-   c                R   ^ U R                  U5      nU R                  UU4S j5      $ )af  Receive a Python object as a message using json to serialize.

Keyword arguments are passed on to json.loads

Parameters
----------
flags : int
    Any valid flags for :func:`Socket.recv`.

Returns
-------
obj : Python object
    The Python object that arrives as a message.

Raises
------
ZMQError
    for any of the reasons :func:`~Socket.recv` might fail
c                2   > [         R                  " U 40 TD6$ r4   )r   rG  )r9  r   s    r*   r:  "Socket.recv_json.<locals>.<lambda>  s    '--2Nv2Nr-   r<  )r)   r   r   r  s     ` r*   	recv_jsonSocket.recv_json  s'    ( ii  &NOOr-   c                    U R                   (       a  [        [        R                  5      eU R	                  5       nUR                  X5        [        UR                  U5      5      nUR                  U S5      $ )a  Poll the socket for events.

See :class:`Poller` to wait for multiple sockets at once.

Parameters
----------
timeout : int
    The timeout (in milliseconds) to wait for an event. If unspecified
    (or specified None), will wait forever for an event.
flags : int
    default: POLLIN.
    POLLIN, POLLOUT, or POLLIN|POLLOUT. The event flags to poll for.

Returns
-------
event_mask : int
    The poll event mask (POLLIN, POLLOUT),
    0 if the timeout was reached without an event.
r   )	r8   r   rX   ENOTSUP_poller_classregisterdictpollr`   )r)   timeoutr   pevtss        r*   rY  Socket.poll  sW    * ;;3;;'' 	

4AFF7O$xxa  r-   c                   [         R                  " 5       S:  a!  [        S[         R                  " 5        35      eU R                  (       a/  U R                  R
                  (       a  SU l        OU R                  $ Uc  SU R                   3nUc  [         R                  nU R                  X!5        U R                  R                  [         R                  5      U l        U R                  R                  U5        U R                  $ )a  Return a connected PAIR socket ready to receive the event notifications.

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

Parameters
----------
events : int
    default: `zmq.EVENT_ALL`
    The bitmask defining which events are wanted.
addr : str
    The optional endpoint for the monitoring sockets.

Returns
-------
socket : zmq.Socket
    The PAIR socket, connected and ready to receive messages.
)   z.get_monitor_socket requires libzmq >= 4, have Nzinproc://monitor.s-)rX   zmq_version_infoNotImplementedErrorzmq_version_monitor_socketr8   r   	EVENT_ALLmonitorr\   r"   PAIRr0   )r)   eventsr%   s      r*   get_monitor_socketSocket.get_monitor_socket*  s    , !D(%@AR@ST 
 ##**'+$+++<(	2D>]]FT"#||22388<$$T*###r-   c                6    SU l         U R                  SS5        g)zsShutdown the PAIR socket (created using get_monitor_socket)
that is serving socket events.

.. versionadded:: 14.4
Nr   )rc  re  r(   s    r*   disable_monitorSocket.disable_monitorY  s      $T1r-   )rc  rY   rZ   rd   r\   r   r   )r)   Socket[bytes]rN   zzmq.ContextrO   r[   rL   
int | None)r)   rm  rR   Socket | intrL   rn  )r)   rm  rN   r   )Nr   )
r)   rm  rN   zzmq.Context | Socket | NonerO   r[   rR   ro  rL   rn  )r)   r   r?   r   r4   )r{   ztype[_SocketType]r   zint | zmq.Socketr?   r   )r?   None)r)   r   r%   r#   r?   r>   )r?   r[   )r   zstr | bytesr?   rp  )utf-8)r   r[   r   r#   r?   rp  )r   r[   r?   r#   )r   r   d   )r)   r   r%   r#   r   r[   r   r[   r   r[   r?   r[   )r   r[   r?   rp  )..)r   r   r   r[   r   boolr   Literal[True]r   rn  r   
str | Noner?   zzmq.MessageTracker)r   r   r   r[   r   rs  r   Literal[False]r   rn  r   ru  r?   rp  ).)r   r   r   r[   r   rs  r   rn  r   ru  r?   rp  ).....)r   r   r   r[   r   rs  r   rs  r   rn  r   ru  r?   zzmq.MessageTracker | None)r   TFNN)r   TF)r  r	   r   r[   r   rs  r   rs  )r   r[   r   rt  r   rs  r?   list[bytes])r   r[   r   rv  r   rs  r?   zlist[zmq.Frame])r   r[   r   rs  r?   rw  )r   r[   r   rs  r   rs  r?   zlist[zmq.Frame] | list[bytes])r%  r   r&  zCallable[[bytes], Any]r?   r   )r   T)r   Trq  )
r4  r#   r   r[   r   rs  r   r#   r?   zmq.Frame | None)r   rq  )r   r[   r   r#   r?   r#   )rB  r   r   r[   rC  r[   r?   rx  )r   )r   r[   r?   r   )rB  r   r   r[   r?   rp  )r   r[   r?   r   )rZ  rn  r   r[   r?   r[   )NN)r)   r   rg  rn  r%   ru  r?   r   )Gr@   rA   rB   rC   rD   rY   rZ   rc  rd   r   r1   rp   rs   r+   r5   r<   r   __deepcopy__classmethodrR   ro   r   r   r/   r0   propertyrO   r   
SocketBaser   
setsockoptr`   r  r   r   r   r   r   setsockopt_unicodesetsockopt_stringr   getsockopt_unicodegetsockopt_stringr   r   r   hwmr  r  r  r'  r-  r1  r5  send_unicoder=  recv_unicodeDEFAULT_PROTOCOLrD  rH  rM  rR  r   rV  rX   POLLINrY  rh  rk  rF   __classcell__)rj   s   @r*   r   r   P   s   , GKOJ &*" 
 #  
 &*	  #	    6:3-
  !%)3-3-23- 3-
 3- #3- 3-j
 I	R6 L# #% %252!#F&< $ $ JJ( 		'	)9* .87*>& .87*
 6D6D6D 6D 	6D
 6D 
6Dp/0 			C  		! "%	!	! 	! 		! 	! 	! 	! 
	! 	!  		 "%		 	 		 	 	 	 
	 	  
 !$ 
    
   !$(( ( 	(
 ( ( ( 
#( ( !% KGKG KG 	KG
 KG KG KG 
#KG KG` 3G3G 3G 	3G
 3Gj FI)6?C	  GJ)7@D	  XX X?D,,$(,8<,	&, ,
 @E#@#@$(#@8<#@	&#@J % 
	,M*6@ OO O 	O
 O 
O4 LH. L &'8H55"5255	584>:&P. M)-CJJ !> JN-$-$#--$<F-$	-$^ r-   
SyncSocket)4rD   
__future__r   r   r@  r   r   typingr   r   r   r   r   r	   r
   r   r   r   warningsr   rX   zmq._typingr   zmq.backendr   r|  	zmq.errorr   r   	zmq.utilsr   zmq.utils.interopr   	constantsr   r   r   	attrsettrr   rY  r   r  r^   HIGHEST_PROTOCOLr   r   rE   r    rH   r   r  __all__rG   r-   r*   <module>r     s    %
 #    
    
 ! , ,  + : : & /.. m84R	9 R.W[) .< -. PZ'2B*C Pf  u
I %\
"}!  /../s   3C CC