Example #1
0
    def __init__(self, serve=None):
        self._ioc = IOCore()
        self.namespaces = set()
        self.resources = set()

        # start services
        serve = serve or []
        if type(serve) not in (tuple, list, set):
            serve = [serve]

        for host in serve:
            self.serve(host)
Example #2
0
 def setup(self):
     self.ioc1 = IOCore(secret='bala')
     self.ioc1.serve('tcp://localhost:9824')
     self.ioc2 = IOCore()
     self.host = self.ioc2.connect('tcp://localhost:9824')
     self.ioc2.register('bala', self.host[1])
Example #3
0
'''
Push/pull using raw IOCore

tcp -- control connection
udp -- data push
'''
from pyroute2 import IOCore
from pyroute2.iocore import NLT_DGRAM


ioc1 = IOCore()
ioc1.serve('tcp://0.0.0.0:9824')
ioc1.serve('udp://0.0.0.0:9824')
ioc1.provide('push')

ioc2 = IOCore()
(uid, addr) = ioc2.connect('tcp://localhost:9824')
ioc2.connect('udp://localhost:9824')
port = ioc2.discover('push', addr)
ioc2.push((addr, port), 'hello, world!', NLT_DGRAM)

print('waiting message from client')
ioc1.monitor()
msg = ioc1.get()[0]

print(msg)
ioc2.release()
ioc1.release()