code: private byte[][] readSocket(ZMQ.Socket socket, int nb) {
          byte[][]    inputs = new byte[nb][];
  
          //  Try to resynchronize if drifts
          if (socket==heartbeatSocket) {
              if (heartbeatDrift>0) {
                  System.err.println("------> try to resynchronize heartbeat (" + heartbeatDrift + ")");
                  for (int i=0 ; i<heartbeatDrift ; i++)
                      heartbeatSocket.recv(0);
                  heartbeatDrift = 0;
              }
          }
          else
          if (socket==eventSocket) {
              if (eventDrift>0) {
                  System.err.println("------> try to resynchronize event (" + eventDrift + ")");
                  for (int i=0 ; i<eventDrift ; i++)
                      eventSocket.recv(0);
                  eventDrift = 0;
              }
          }
  
  
          //  Read the socket for nb blocks
          for (int i=0 ; i<nb ; i++) {
              inputs[i] = socket.recv(0);
          }
          return inputs;
      }
docs: ===============================================================