SNode.C
Loading...
Searching...
No Matches
httplowlevelclient.cpp File Reference
Include dependency graph for httplowlevelclient.cpp:

Go to the source code of this file.

Classes

class  apps::http::SimpleSocketProtocol
class  apps::http::SimpleSocketProtocolFactory

Namespaces

namespace  apps
namespace  apps::http
namespace  tls
namespace  legacy

Typedefs

using tls::SocketClient = net::in::stream::tls::SocketClient<apps::http::SimpleSocketProtocolFactory>
using tls::SocketAddress = SocketClient::SocketAddress
using tls::SocketConnection = SocketClient::SocketConnection
using legacy::SocketClient = net::in::stream::legacy::SocketClient<apps::http::SimpleSocketProtocolFactory>
using legacy::SocketAddress = SocketClient::SocketAddress
using legacy::SocketConnection = SocketClient::SocketConnection

Functions

static web::http::client::ResponseParserapps::http::getResponseParser (core::socket::stream::SocketContext *socketContext)
SocketClient tls::getClient ()
SocketClient legacy::getLegacyClient ()
int main (int argc, char *argv[])

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 310 of file httplowlevelclient.cpp.

310 {
311 core::SNodeC::init(argc, argv);
312
313 {
314 const legacy::SocketAddress legacyRemoteAddress("localhost", 8080);
315
316 const legacy::SocketClient legacyClient = legacy::getLegacyClient();
317
318 legacyClient.connect(legacyRemoteAddress,
319 [instanceName = legacyClient.getConfig().getInstanceName()](
320 const tls::SocketAddress& socketAddress,
321 const core::socket::State& state) { // example.com:81 simulate connnect timeout
322 switch (state) {
323 case core::socket::State::OK:
324 VLOG(1) << instanceName << ": connected to '" << socketAddress.toString() << "'";
325 break;
326 case core::socket::State::DISABLED:
327 VLOG(1) << instanceName << ": disabled";
328 break;
329 case core::socket::State::ERROR:
330 LOG(ERROR) << instanceName << ": " << socketAddress.toString() << ": " << state.what();
331 break;
332 case core::socket::State::FATAL:
333 LOG(FATAL) << instanceName << ": " << socketAddress.toString() << ": " << state.what();
334 break;
335 }
336 });
337
338 const tls::SocketAddress tlsRemoteAddress = tls::SocketAddress("localhost", 8088);
339
340 const tls::SocketClient tlsClient = tls::getClient();
341
342 tlsClient.connect(tlsRemoteAddress,
343 [instanceName = tlsClient.getConfig().getInstanceName()](
344 const tls::SocketAddress& socketAddress,
345 const core::socket::State& state) { // example.com:81 simulate connnect timeout
346 switch (state) {
347 case core::socket::State::OK:
348 VLOG(1) << instanceName << ": connected to '" << socketAddress.toString() << "'";
349 break;
350 case core::socket::State::DISABLED:
351 VLOG(1) << instanceName << ": disabled";
352 break;
353 case core::socket::State::ERROR:
354 LOG(ERROR) << instanceName << ": " << socketAddress.toString() << ": " << state.what();
355 break;
356 case core::socket::State::FATAL:
357 LOG(FATAL) << instanceName << ": " << socketAddress.toString() << ": " << state.what();
358 break;
359 }
360 });
361 }
362
363 return core::SNodeC::start();
364}
static void init(int argc, char *argv[])
Definition SNodeC.cpp:54
static int start(const utils::Timeval &timeOut={LONG_MAX, 0})
Definition SNodeC.cpp:60
Config & getConfig() const
Definition Socket.hpp:65
const Super & connect(const std::string &ipOrHostname, uint16_t port, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
net::in::stream::legacy::SocketClient< apps::http::SimpleSocketProtocolFactory > SocketClient
SocketClient::SocketAddress SocketAddress
SocketClient getLegacyClient()
net::in::stream::tls::SocketClient< apps::http::SimpleSocketProtocolFactory > SocketClient
SocketClient getClient()
SocketClient::SocketAddress SocketAddress

References core::socket::stream::SocketClient< SocketConnectorT, SocketContextFactoryT, Args >::connect(), core::socket::State::DISABLED, core::socket::State::ERROR, core::socket::State::FATAL, tls::getClient(), core::socket::Socket< ConfigT >::getConfig(), net::config::ConfigInstance::getInstanceName(), legacy::getLegacyClient(), core::SNodeC::init(), core::socket::State::OK, net::in::SocketAddress::SocketAddress(), core::SNodeC::start(), net::in::SocketAddress::toString(), and core::socket::State::what().

Here is the call graph for this function: