ZIO
Python and C++ interface to ZeroMQ and Zyre
Public Member Functions | Public Attributes | List of all members
zio.port.Port Class Reference

Public Member Functions

def __init__ (self, name, sock, hostname='127.0.0.1')
 
def __str__ (self)
 
def bind (self, spec)
 
def connect (self, spec)
 
def subscribe (self, prefix="")
 
def add_headers (self, args, kwargs)
 
def do_binds (self)
 
def online (self, peer=None)
 
def offline (self)
 
def send (self, msg)
 
def recv (self, timeout=None)
 

Public Attributes

 name
 
 ctx
 
 sock
 
 origin
 
 to_bind
 
 to_conn
 
 headers
 
 is_online
 
 connected
 
 bound
 
 poller
 

Detailed Description

Definition at line 52 of file port.py.

Constructor & Destructor Documentation

◆ __init__()

def zio.port.Port.__init__ (   self,
  name,
  sock,
  hostname = '127.0.0.1' 
)
Create a Port with a name and a ZeroMQ socket type.

Ports are typically not meant to be constructed directly by
application code but instead through a managing zio.Node

Definition at line 53 of file port.py.

Member Function Documentation

◆ __str__()

def zio.port.Port.__str__ (   self)

Definition at line 77 of file port.py.

◆ add_headers()

def zio.port.Port.add_headers (   self,
  args,
  kwargs 
)
Add one or more headers or dictionaries of headers.

Every key will be wrapped into ZIO port header convention.
The headers will appear to the network as

zio.port.<portname>.<key> = <value>

The self.headers collects these.

Definition at line 123 of file port.py.

◆ bind()

def zio.port.Port.bind (   self,
  spec 
)
Request a bind.

If spec is None, do a default/ephemeral bind.
If spec is a string, it is assumed to be a ZeroMQ adddress.
If spec is a tuple ithen it is a (hostname,portnumber).

Definition at line 83 of file port.py.

◆ connect()

def zio.port.Port.connect (   self,
  spec 
)
Request a connect.

If a single string is given it is a ZeroMQ address.
If two strings are given they are (nodename, portname).

Definition at line 100 of file port.py.

◆ do_binds()

def zio.port.Port.do_binds (   self)
Actually perform binds.

Return dictionary suitable for use as peer headers the give
information about the binds.

This must be called prior to any call of .online() and is
intended to be used by a zio.Node which holds this zio.Port.

Definition at line 140 of file port.py.

◆ offline()

def zio.port.Port.offline (   self)
Bring this port offline.

This unbinds and disconnects and forgets their addresses

Definition at line 204 of file port.py.

◆ online()

def zio.port.Port.online (   self,
  peer = None 
)
Bring this port online.

If no peer is given then indirect connects will fail.

This method is intended for use by a zio.Node which holds this
zio.Port.

Definition at line 164 of file port.py.

◆ recv()

def zio.port.Port.recv (   self,
  timeout = None 
)
Receive and return a zio.Message waiting up to a timeout 

If timeout is reached then None is returned.

Definition at line 239 of file port.py.

◆ send()

def zio.port.Port.send (   self,
  msg 
)
Send a zio.Message

This modifies the message prior to sending to set the origin
if this port has one.

Definition at line 219 of file port.py.

◆ subscribe()

def zio.port.Port.subscribe (   self,
  prefix = "" 
)
Subscribe to a PUB/SUB topic.

This method is only meaningful if our socket is a SUB and then
it MUST be called if messages are expected to be received.

Definition at line 111 of file port.py.

Member Data Documentation

◆ bound

zio.port.Port.bound

Definition at line 73 of file port.py.

◆ connected

zio.port.Port.connected

Definition at line 72 of file port.py.

◆ ctx

zio.port.Port.ctx

Definition at line 63 of file port.py.

◆ headers

zio.port.Port.headers

Definition at line 70 of file port.py.

◆ is_online

zio.port.Port.is_online

Definition at line 71 of file port.py.

◆ name

zio.port.Port.name

Definition at line 60 of file port.py.

◆ origin

zio.port.Port.origin

Definition at line 67 of file port.py.

◆ poller

zio.port.Port.poller

Definition at line 74 of file port.py.

◆ sock

zio.port.Port.sock

Definition at line 64 of file port.py.

◆ to_bind

zio.port.Port.to_bind

Definition at line 68 of file port.py.

◆ to_conn

zio.port.Port.to_conn

Definition at line 69 of file port.py.


The documentation for this class was generated from the following file: