예제 #1
0
    def __init__(self, receiveCb, afIEndpoint, afOEndpoint):
        signal.signal(signal.SIGINT, self.signal_handler)

        self.zcontext = zmq.Context(1)
        self.orclient = orsoqs.create_client()
        self.osocket = orsoqs.connect(self.orclient, afIEndpoint,
                                      orsoqs.CON_PUSH)
        self.isocket = orsoqs.connect(self.orclient, afOEndpoint,
                                      orsoqs.CON_WAIT)
        self.isocket.set_proc_callback(self.listen_cb)
예제 #2
0
 def __init__(self, receiveCb, afIEndpoint, afOEndpoint, basesFile):
     signal.signal(signal.SIGINT, self.signal_handler)
     
     self.zcontext = zmq.Context(1)
     self.orclient = orsoqs.create_client()
     self.osocket = orsoqs.connect(self.orclient, afIEndpoint, orsoqs.CON_PUSH)
     self.isocket = orsoqs.connect(self.orclient, afOEndpoint, orsoqs.CON_WAIT)
     self.isocket.set_proc_callback(self.listen_cb)
     
     self.bases = open(basesFile)
     self.basisLoc = 0
     self.basis = ord(self.bases.read(1))
     
     self.ber = Queue()
     self.plotter = threading.Thread(target=self.plotter)
     self.plotter.start()
예제 #3
0
def check_con_wait(endpoint):
    '''
	Check out wait type connection.
	'''
    orclient = orsoqs.create_client()
    orsocket = orsoqs.connect(orclient, endpoint, orsoqs.CON_WAIT)
    orsocket.set_proc_callback(proc_cb)

    c = zmq.Context()
    s = c.socket(zmq.PAIR)
    s.bind(endpoint)
    s.send(dataToRequest)

    assert s.recv() == dataToReply

    s.unbind(endpoint)
    s.close()
    orsoqs.disconnect(orsocket)
    orsoqs.delete_client(orclient)
예제 #4
0
def check_con_request(endpoint):
    '''
	Check our request type connection.
	'''
    listenThread = multiprocessing.Process(target=zsocket_listen,
                                           args=(endpoint, dataToRequest,
                                                 dataToReply))
    listenThread.daemon = True
    listenThread.start()

    orclient = orsoqs.create_client()
    orsocket = orsoqs.connect(orclient, endpoint, orsoqs.CON_REQUEST)
    msg = orsoqs.create_msg(dataToRequest, len(dataToRequest))

    rmsg = orsoqs.send_msg(orsocket, msg)

    assert rmsg.str() == dataToReply

    orsoqs.delete_msg(msg)
    orsoqs.delete_msg(rmsg)
    orsoqs.disconnect(orsocket)
    orsoqs.delete_client(orclient)

    listenThread.join()