namespace samples::tcp {
public:
static constexpr std::string_view kName = "tcp-hello";
: TcpAcceptorBase(config, context),
greeting_(config["greeting"].As<std::string>("hi")) {}
private:
const std::string greeting_;
};
}
namespace samples::tcp {
std::string data;
data.resize(2);
const auto read_bytes = sock.ReadAll(data.data(), 2, {});
if (read_bytes != 2 || data != "hi") {
sock.Close();
return;
}
const auto sent_bytes =
sock.SendAll(greeting_.data(), greeting_.size(), {});
if (sent_bytes != greeting_.size()) {
return;
}
}
}
return yaml_config::MergeSchemas<TcpAcceptorBase>(R"(
type: object
description: |
Component for accepting incoming TCP connections and responding with some
greeting as long as the client sends 'hi'.
additionalProperties: false
properties:
greeting:
type: string
description: greeting to send to client
defaultDescription: hi
)");
}
}
int main(int argc, const char* const argv[]) {
const auto component_list =
}