SNode.C
Loading...
Searching...
No Matches
legacy Namespace Reference

Typedefs

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

Functions

SocketClient getLegacyClient ()
 

Typedef Documentation

◆ SocketAddress

Definition at line 283 of file httplowlevelclient.cpp.

◆ SocketClient

◆ SocketConnection

Function Documentation

◆ getLegacyClient()

SocketClient legacy::getLegacyClient ( )
private

Definition at line 286 of file httplowlevelclient.cpp.

286 {
287 SocketClient legacyClient(
288 "legacy",
289 [](SocketConnection* socketConnection) { // OnConnect
290 VLOG(1) << "OnConnect";
291
292 VLOG(1) << "\tServer: " << socketConnection->getRemoteAddress().toString();
293 VLOG(1) << "\tClient: " << socketConnection->getLocalAddress().toString();
294 },
295 [](SocketConnection* socketConnection) { // onConnected
296 VLOG(1) << "OnConnected";
297
298 socketConnection->sendToPeer("GET /index.html HTTP/1.1\r\nConnection: close\r\n\r\n"); // Connection: close\r\n\r\n");
299 },
300 [](SocketConnection* socketConnection) { // onDisconnect
301 VLOG(1) << "OnDisconnect";
302
303 VLOG(1) << "\tServer: " << socketConnection->getRemoteAddress().toString();
304 VLOG(1) << "\tClient: " << socketConnection->getLocalAddress().toString();
305 });
306
307 SocketAddress remoteAddress("localhost", 8080);
308
309 remoteAddress.init();
310
311 VLOG(1) << "###############': " << remoteAddress.getCanonName();
312 VLOG(1) << "###############': " << remoteAddress.toString();
313
314 legacyClient.connect(remoteAddress,
315 [instanceName = legacyClient.getConfig().getInstanceName()](
316 const tls::SocketAddress& socketAddress,
317 const core::socket::State& state) { // example.com:81 simulate connnect timeout
318 switch (state) {
319 case core::socket::State::OK:
320 VLOG(1) << instanceName << ": connected to '" << socketAddress.toString() << "'";
321 break;
322 case core::socket::State::DISABLED:
323 VLOG(1) << instanceName << ": disabled";
324 break;
325 case core::socket::State::ERROR:
326 LOG(ERROR) << instanceName << ": " << socketAddress.toString() << ": " << state.what();
327 break;
328 case core::socket::State::FATAL:
329 LOG(FATAL) << instanceName << ": " << socketAddress.toString() << ": " << state.what();
330 break;
331 }
332 });
333
334 return legacyClient;
335 }
Client::SocketConnection SocketConnection
Definition clients.h:88
SocketClient::SocketConnection SocketConnection
SocketClient::SocketAddress SocketAddress

References core::socket::stream::SocketClient< SocketConnectorT, SocketContextFactoryT, Args >::connect(), core::socket::State::DISABLED, core::socket::State::ERROR, core::socket::State::FATAL, net::in::SocketAddress::getCanonName(), core::socket::Socket< ConfigT >::getConfig(), net::config::ConfigInstance::getInstanceName(), core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >::getLocalAddress(), core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >::getRemoteAddress(), net::in::SocketAddress::init(), core::socket::State::OK, core::socket::stream::SocketConnection::sendToPeer(), net::in::SocketAddress::SocketAddress(), net::in::SocketAddress::toString(), and core::socket::State::what().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function: