0MQ Socket class.
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
socket_type : int
|
|---|
See also
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
|
|---|
Bind this socket to a random port in a range.
| Parameters : | addr : str
min_port : int, optional
max_port : int, optional
max_tries : int, optional
|
|---|---|
| Returns : | port : int
|
| Raises : | ZMQBindError :
|
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.
Connect to a remote 0MQ socket.
| Parameters : | addr : str
|
|---|
Get the value of a socket option.
See the 0MQ API documentation for details on specific options.
| Parameters : | option : int
|
|---|---|
| Returns : | optval : int or bytes
|
Get the value of a socket option.
See the 0MQ documentation for details on specific options.
| Parameters : | option : int
|
|---|---|
| Returns : | optval : unicode string (unicode on py2, str on py3)
|
Get the value of a socket option.
See the 0MQ documentation for details on specific options.
| Parameters : | option : int
|
|---|---|
| Returns : | optval : unicode string (unicode on py2, str on py3)
|
Poll the socket for events. The default is to poll forever for incoming events. Timeout is in milliseconds, if specified.
| Parameters : | timeout : int [default: None]
flags : bitfield (int) [default: POLLIN]
|
|---|---|
| Returns : | events : bitfield (int)
|
Receive a message.
| Parameters : | flags : int
copy : bool
track : bool
|
|---|---|
| Returns : | msg : bytes, Frame
|
| Raises : | ZMQError :
|
Receive a Python object as a message using json to serialize.
| Parameters : | flags : int
|
|---|---|
| Returns : | obj : Python object
|
Receive a multipart message as a list of bytes or Frame objects.
| Parameters : | flags : int, optional
copy : bool, optional
track : bool, optional
Returns : ——- : msg_parts : list
|
|---|
Receive a Python object as a message using pickle to serialize.
| Parameters : | flags : int
|
|---|---|
| Returns : | obj : Python object
|
Receive a unicode string, as sent by send_string.
| Parameters : | flags : int
encoding : str [default: ‘utf-8’]
|
|---|---|
| Returns : | s : unicode string (unicode on py2, str on py3)
|
Receive a unicode string, as sent by send_string.
| Parameters : | flags : int
encoding : str [default: ‘utf-8’]
|
|---|---|
| Returns : | s : unicode string (unicode on py2, str on py3)
|
Send a message on this socket.
This queues the message to be sent by the IO thread at a later time.
| Parameters : | data : object, str, Frame
flags : int
copy : bool
track : bool
|
|---|---|
| Returns : | None : if copy or not track
MessageTracker : if track and not copy
|
| Raises : | TypeError :
ValueError :
ZMQError :
|
Send a Python object as a message using json to serialize.
| Parameters : | obj : Python object
flags : int
|
|---|
Send a sequence of buffers as a multipart message.
| Parameters : | msg_parts : iterable
flags : int, optional
copy : bool, optional
track : bool, optional
|
|---|---|
| Returns : | None : if copy or not track MessageTracker : if track and not copy
|
Send a Python object as a message using pickle to serialize.
| Parameters : | obj : Python object
flags : int
protocol : int
|
|---|
Send a Python unicode string as a message with an encoding.
0MQ communicates with raw bytes, so you must encode/decode text (unicode on py2, str on py3) around 0MQ.
| Parameters : | u : Python unicode string (unicode on py2, str on py3)
flags : int, optional
encoding : str [default: ‘utf-8’]
|
|---|
Send a Python unicode string as a message with an encoding.
0MQ communicates with raw bytes, so you must encode/decode text (unicode on py2, str on py3) around 0MQ.
| Parameters : | u : Python unicode string (unicode on py2, str on py3)
flags : int, optional
encoding : str [default: ‘utf-8’]
|
|---|
Set socket options.
See the 0MQ API documentation for details on specific options.
| Parameters : | option : int
optval : int or bytes
|
|---|
Set socket options with a unicode object it is simply a wrapper for setsockopt to protect from encoding ambiguity.
See the 0MQ documentation for details on specific options.
| Parameters : | option : int
optval : unicode string (unicode on py2, str on py3)
encoding : str
|
|---|
Set socket options with a unicode object it is simply a wrapper for setsockopt to protect from encoding ambiguity.
See the 0MQ documentation for details on specific options.
| Parameters : | option : int
optval : unicode string (unicode on py2, str on py3)
encoding : str
|
|---|