SNode.C
Loading...
Searching...
No Matches
httpclientclientcert.cpp
Go to the documentation of this file.
1/*
2 * SNode.C - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "apps/http/model/clients.h"
21#include "core/SNodeC.h"
22
23#ifndef DOXYGEN_SHOULD_SKIP_THIS
24
25#include "log/Logger.h"
26
27#include <string>
28
29#endif /* DOXYGEN_SHOULD_SKIP_THIS */
30
31int main(int argc, char* argv[]) {
32 core::SNodeC::init(argc, argv);
33
34 using Client = apps::http::STREAM::Client;
35 using SocketAddress = Client::SocketAddress;
36
37 const Client client = apps::http::STREAM::getClient();
38
39 client.connect([instanceName = client.getConfig().getInstanceName()](
40 const SocketAddress& socketAddress,
41 const core::socket::State& state) { // example.com:81 simulate connnect timeout
42 switch (state) {
43 case core::socket::State::OK:
44 VLOG(1) << instanceName << ": connected to '" << socketAddress.toString() << "'";
45 break;
46 case core::socket::State::DISABLED:
47 VLOG(1) << instanceName << ": disabled";
48 break;
49 case core::socket::State::ERROR:
50 LOG(ERROR) << instanceName << ": " << socketAddress.toString() << ": " << state.what();
51 break;
52 case core::socket::State::FATAL:
53 LOG(FATAL) << instanceName << ": " << socketAddress.toString() << ": " << state.what();
54 break;
55 }
56 });
57 return core::SNodeC::start();
58}
59
60/*
61#if (NET_TYPE == IN) // in
62#if (STREAM_TYPE == LEGACY)
63 client.connect("localhost", 8080, [](int errnum) {
64#elif (STREAM_TYPE == TLS)
65 client.connect("localhost", 8088, [](int errnum) {
66#endif
67#elif (NET_TYPE == IN6) // in6
68#if (STREAM_TYPE == LEGACY)
69 client.connect("localhost", 8080, [](int errnum) {
70#elif (STREAM_TYPE == TLS)
71 client.connect("localhost", 8088, [](int errnum) {
72#endif
73#elif (NET_TYPE == L2) // l2
74 // ATLAS: 10:3D:1C:AC:BA:9C
75 // TITAN: A4:B1:C1:2C:82:37
76 // USB: 44:01:BB:A3:63:32
77
78 // client.connect("A4:B1:C1:2C:82:37", 0x1023, "44:01:BB:A3:63:32", [](int errnum) {
79 client.connect("10:3D:1C:AC:BA:9C", 0x1023, "44:01:BB:A3:63:32", [](int errnum) {
80#elif (NET_TYPE == RC) // rf
81 // client.connect("A4:B1:C1:2C:82:37", 1, "44:01:BB:A3:63:32", [](int errnum) {
82 client.connect("10:3D:1C:AC:BA:9C", 1, "44:01:BB:A3:63:32", [](int errnum) {
83#elif (NET_TYPE == UN) // un
84 client.connect("/tmp/testme", [](int errnum) {
85#endif
86 if (errnum != 0) {
87 PLOG(ERROR) << "OnError: " << errnum;
88 } else {
89 VLOG(1) << "snode.c connected";
90 }
91
92#ifdef NET_TYPE
93 });
94#endif
95*/
int main(int argc, char *argv[])