code: def __init__(self, interface="tcp://*", identity=None):
      self._ctx = zmq.Context()
      self.socket = self._ctx.socket(zmq.XREP)
      self.pub = self._ctx.socket(zmq.PUB)
      self.sub = self._ctx.socket(zmq.SUB)
  
      # configure sockets
      self.identity = identity or bytes(uuid.uuid4())
      self.socket.IDENTITY = self.identity
      self.sub.SUBSCRIBE = b""
  
      # bind to ports
      port = self.socket.bind_to_random_port(interface)
      pub_port = self.pub.bind_to_random_port(interface)
      self.url = interface + ":%i" % port
      self.pub_url = interface + ":%i" % pub_port
      # guess first public IP from socket
      self.location = socket.gethostbyname_ex(socket.gethostname())[-1][
          0
      ]
      self.peers = {}
  
file_path: ipyparallel/examples/interengine/communicator.py
imports: import socket
  import uuid
  import zmq
  from ipyparallel.util import disambiguate_url
label_desc: Use image node_id 1 to create a new EngineCommunicator object  with example: obj = EngineCommunicator(interface, identity)