code: private void connectIfNotDone(ZMQ.Socket socket, ZMQutils.ControlStructure controlStructure){
  
          traceZmqSubscription(controlStructure.eventName, true);
          //  Check if not already connected or forced (re connection)
          if (controlStructure.forceReconnection || !alreadyConnected(controlStructure.endPoint)) {
              ApiUtil.printTrace("Set socket buffer for HWM to " + controlStructure.hwm);
  
              //  Check if it ia a reconnection -> disconnect before connection
              if (controlStructure.forceReconnection && alreadyConnected(controlStructure.endPoint)) {
                  try {
                      //  needs an un subscribe before disconnection
                      //socket.unsubscribe(controlStructure.eventName.getBytes());
                      socket.disconnect(controlStructure.endPoint);
                  }
                  catch (org.zeromq.ZMQException e) {
                      System.err.println(e.getMessage());
                  }
              }
  
              //  Do the connection
              //System.out.println("Connect on " + controlStructure.endPoint);
              //System.out.println("        for " + controlStructure.eventName);
              socket.setHWM(controlStructure.hwm);
              socket.connect(controlStructure.endPoint);
              if (!alreadyConnected(controlStructure.endPoint)) {
                  EventList eventList = new EventList();
                  eventList.add(controlStructure.eventName);
                  connectedMap.put(controlStructure.endPoint, eventList);
              }
              else {
                  //  Add to event list if not done
                  EventList eventList = connectedMap.get(controlStructure.endPoint);
                  String  s = eventList.getEvent(controlStructure.eventName);
                  if (s==null)
                      eventList.add(controlStructure.eventName);
              }
          }
          else {
              //  Add to event list if not done
              EventList eventList = connectedMap.get(controlStructure.endPoint);
              String  s = eventList.getEvent(controlStructure.eventName);
              if (s==null)
                  eventList.add(controlStructure.eventName);
              ApiUtil.printTrace(
                      ((controlStructure.commandCode==ZMQutils.ZMQ_CONNECT_EVENT)? "Event" : "Heartbeat") +
                      " already connected to " + controlStructure.endPoint);
          }
      }
docs: ===============================================================