  std::vector<int32_t> getTimestampNotifications() noexcept {
    auto fd = socket_->getNetworkSocket();
    std::vector<char> ctrl(1024, 0);
    unsigned char data;
    struct msghdr msg;
    iovec entry;

    memset(&msg, 0, sizeof(msg));
    entry.iov_base = &data;
    entry.iov_len = sizeof(data);
    msg.msg_iov = &entry;
    msg.msg_iovlen = 1;
    msg.msg_control = ctrl.data();
    msg.msg_controllen = ctrl.size();

    std::vector<int32_t> timestampsFound;

    folly::Optional<int32_t> timestampType;
    bool gotTimestamp = false;
    bool gotByteSeq = false;
    int ret;
    while (true) {
      ret = netops::recvmsg(fd, &msg, MSG_ERRQUEUE);
      if (ret < 0) {
        if (errno != EAGAIN) {
          auto errnoCopy = errno;
          std::cerr << "::recvmsg exited with code " << ret
                    << ", errno: " << errnoCopy << std::endl;
          AsyncSocketException ex(
              AsyncSocketException::INTERNAL_ERROR,
              "recvmsg() failed",
              errnoCopy);
          exception = ex;
        }
        return timestampsFound;
      }

      for (struct cmsghdr* cmsg = CMSG_FIRSTHDR(&msg);
           cmsg != nullptr && cmsg->cmsg_len != 0;
           cmsg = CMSG_NXTHDR(&msg, cmsg)) {
        if (cmsg->cmsg_level == SOL_SOCKET &&
            cmsg->cmsg_type == SCM_TIMESTAMPING) {
          CHECK(!gotTimestamp); // shouldn't already be set
          gotTimestamp = true;
        }

        if ((cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_RECVERR) ||
            (cmsg->cmsg_level == SOL_IPV6 && cmsg->cmsg_type == IPV6_RECVERR)) {
          const struct cmsghdr& cmsgh = *cmsg;
          const auto serr = reinterpret_cast<const struct sock_extended_err*>(
              CMSG_DATA(&cmsgh));
          if (serr->ee_errno != ENOMSG ||
              serr->ee_origin != SO_EE_ORIGIN_TIMESTAMPING) {
            // not a timestamp
            continue;
          }

          CHECK(!timestampType); // shouldn't already be set
          CHECK(!gotByteSeq); // shouldn't already be set
          gotByteSeq = true;
          timestampType = serr->ee_info;
        }

        // check if we have both a timestamp and byte sequence
        if (gotTimestamp && gotByteSeq) {
          timestampsFound.push_back(*timestampType);
          timestampType = folly::none;
          gotTimestamp = false;
          gotByteSeq = false;
        }
      } // for(...)
    } // while(true)

    return timestampsFound;
  }
  std::vector<int32_t> getTimestampNotifications() noexcept {
    auto fd = socket_->getNetworkSocket();
    std::vector<char> ctrl(1024, 0);
    unsigned char data;
    struct msghdr msg;
    iovec entry;

    memset(&msg, 0, sizeof(msg));
    entry.iov_base = &data;
    entry.iov_len = sizeof(data);
    msg.msg_iov = &entry;
    msg.msg_iovlen = 1;
    msg.msg_control = ctrl.data();
    msg.msg_controllen = ctrl.size();

    std::vector<int32_t> timestampsFound;

    folly::Optional<int32_t> timestampType;
    bool gotTimestamp = false;
    bool gotByteSeq = false;
    int ret;
    while (true) {
      ret = netops::recvmsg(fd, &msg, MSG_ERRQUEUE);
      if (ret < 0) {
        if (errno != EAGAIN) {
          auto errnoCopy = errno;
          std::cerr << "::recvmsg exited with code " << ret
                    << ", errno: " << errnoCopy << std::endl;
          AsyncSocketException ex(
              AsyncSocketException::INTERNAL_ERROR,
              "recvmsg() failed",
              errnoCopy);
          exception = ex;
        }
        return timestampsFound;
      }

      for (struct cmsghdr* cmsg = CMSG_FIRSTHDR(&msg);
           cmsg != nullptr && cmsg->cmsg_len != 0;
           cmsg = CMSG_NXTHDR(&msg, cmsg)) {
        if (cmsg->cmsg_level == SOL_SOCKET &&
            cmsg->cmsg_type == SCM_TIMESTAMPING) {
          CHECK(!gotTimestamp);  
          gotTimestamp = true;
        }

        if ((cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_RECVERR) ||
            (cmsg->cmsg_level == SOL_IPV6 && cmsg->cmsg_type == IPV6_RECVERR)) {
          const struct cmsghdr& cmsgh = *cmsg;
          const auto serr = reinterpret_cast<const struct sock_extended_err*>(
              CMSG_DATA(&cmsgh));
          if (serr->ee_errno != ENOMSG ||
              serr->ee_origin != SO_EE_ORIGIN_TIMESTAMPING) {
             
            continue;
          }

          CHECK(!timestampType);  
          CHECK(!gotByteSeq);  
          gotByteSeq = true;
          timestampType = serr->ee_info;
        }

         
        if (gotTimestamp && gotByteSeq) {
          timestampsFound.push_back(*timestampType);
          timestampType = folly::none;
          gotTimestamp = false;
          gotByteSeq = false;
        }
      }  
    }  

    return timestampsFound;
  }