'Create a bound socket pair using a random port.'

def create_bound_pair(self, type1=zmq.PAIR, type2=zmq.PAIR, interface='tcp://127.0.0.1'):

    s1 = self.context.socket(type1)
    s1.setsockopt(zmq.LINGER, 0)
    port = s1.bind_to_random_port(interface)
    s2 = self.context.socket(type2)
    s2.setsockopt(zmq.LINGER, 0)
    s2.connect(('%s:%s' % (interface, port)))
    self.sockets.extend([s1, s2])
    return (s1, s2)
