peary/interfaces/IPSocket/ipsocket.hpp

Peary IPSocketb Interface. More…

Namespaces

Name
peary
peary::interface

Classes

Name
struct peary::interface::IPSocketInterface
class peary::interface::IPSocketEndpoint Configuration class for IPSocket interface.

Detailed Description

Peary IPSocketb Interface.

Copyright: Copyright (c) 2016-2025 CERN and the Peary Caribou authors. This software is distributed under the terms of the LGPL-3.0-only License, copied verbatim in the file “LICENSE.md”. SPDX-License-Identifier: LGPL-3.0-only

Source code

  
#pragma once

#include <cstdint>
#include <string>
#include <vector>

#include "peary/interfaces/Endpoint.hpp"
#include "peary/utils/exceptions.hpp"

namespace peary::interface {

    struct IPSocketInterface {};

    class IPSocketEndpoint : public Endpoint<IPSocketInterface, std::string, std::string> {

    public:
        explicit IPSocketEndpoint(const std::string& address, uint32_t port);

        ~IPSocketEndpoint() override;

    protected:
        data_t write_impl(const data_t& payload) override;

        vector_t read_impl(const reg_t& query, const unsigned int length) override;

        std::vector<uint8_t> read_binary(const reg_t& query, const unsigned int length);

    private:
        // Called from read() and write() while holding the lock
        data_t write_nolock(const data_t& payload);

        std::string trim(const std::string& str, const std::string& delims = " \t\n\r\v");

        std::string clean_command(std::string& command);

        // Remote socket to connect to
        int mysocket_;
    };

} // namespace peary::interface
  

Updated on 2026-01-30 at 22:01:05 +0100