Esempio n. 1
0
from twisted.internet import reactor

from zmqproto import ZmqSocket

if __name__ == '__main__':
    def frame_arrived(frame, is_command):
        print "frame arrived", frame, is_command

    print "Create test client"
    p1 = ZmqSocket(frame_arrived, version=1, type='SUB')
    p1.connect('tcp://85.25.198.97:9094') # block publish
    #p1.connect('tcp://127.0.0.1:5556') # block publish
    #p2 = ZmqSocket(frame_arrived, version=2, type='SUB')
    #p2.connect('tcp://85.25.198.97:9094') # block publish
    #p2.connect('tcp://127.0.0.1:5556') # block publish
    reactor.run()

Esempio n. 2
0
from zmqproto.zmq3 import Zmq3Protocol
from zmqproto.zmq2 import Zmq2Protocol
from zmqproto.zmq1 import Zmq1Protocol

def test_protocol(proto):
    greeting = proto.buildGreeting()
    handshake = proto.buildReadyHandshake()
    prop1 = proto.buildProperty('Socket-Type', 'DEALER')
    prop2 = proto.buildProperty('Identity', '')

    proto.dataReceived(greeting[:4])
    proto.dataReceived(greeting[4:12])
    proto.dataReceived(greeting[12:16])
    proto.dataReceived(greeting[16:])
    proto.dataReceived(proto.buildFrame(handshake+prop1+prop2))

if __name__ == '__main__':

    for proto in [Zmq1Protocol(), Zmq2Protocol(), Zmq3Protocol()]:
        print "Test protocol", proto
        test_protocol(proto)

    def frame_arrived(self, frame, is_command, wants_more):
        print "frame arrived", is_command, wants_more

    print "Create test client"
    p = ZmqSocket(frame_arrived)
    p.connect('tcp://192.168.1.171:9091')
    reactor.run()

Esempio n. 3
0
 def setup(self, address):
     s = ZmqSocket(self.frame_received)
     s.connect(address)
     return s
Esempio n. 4
0
from twisted.internet import reactor

from zmqproto import ZmqSocket

if __name__ == '__main__':

    def frame_arrived(frame, is_command):
        print "frame arrived", frame, is_command

    print "Create test client"
    p1 = ZmqSocket(frame_arrived, version=1, type='SUB')
    p1.connect('tcp://85.25.198.97:9094')  # block publish
    #p1.connect('tcp://127.0.0.1:5556') # block publish
    #p2 = ZmqSocket(frame_arrived, version=2, type='SUB')
    #p2.connect('tcp://85.25.198.97:9094') # block publish
    #p2.connect('tcp://127.0.0.1:5556') # block publish
    reactor.run()