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

◆ SocketClient

◆ SocketConnection

Function Documentation

◆ getLegacyClient()

SocketClient legacy::getLegacyClient ( )

Definition at line 257 of file httplowlevelclient.cpp.

257 {
258 SocketClient legacyClient(
259 "legacy",
260 [](SocketConnection* socketConnection) { // OnConnect
261 VLOG(1) << "OnConnect";
262
263 VLOG(1) << "\tServer: " << socketConnection->getRemoteAddress().toString();
264 VLOG(1) << "\tClient: " << socketConnection->getLocalAddress().toString();
265 },
266 [](SocketConnection* socketConnection) { // onConnected
267 VLOG(1) << "OnConnected";
268
269 socketConnection->sendToPeer("GET /index.html HTTP/1.1\r\nConnection: close\r\n\r\n"); // Connection: close\r\n\r\n");
270 },
271 [](SocketConnection* socketConnection) { // onDisconnect
272 VLOG(1) << "OnDisconnect";
273
274 VLOG(1) << "\tServer: " << socketConnection->getRemoteAddress().toString();
275 VLOG(1) << "\tClient: " << socketConnection->getLocalAddress().toString();
276 });
277
278 SocketAddress remoteAddress("localhost", 8080);
279
280 remoteAddress.init();
281
282 VLOG(1) << "###############': " << remoteAddress.getCanonName();
283 VLOG(1) << "###############': " << remoteAddress.toString();
284
285 legacyClient.connect(remoteAddress,
286 [instanceName = legacyClient.getConfig().getInstanceName()](
287 const tls::SocketAddress& socketAddress,
288 const core::socket::State& state) { // example.com:81 simulate connnect timeout
289 switch (state) {
290 case core::socket::State::OK:
291 VLOG(1) << instanceName << ": connected to '" << socketAddress.toString() << "'";
292 break;
293 case core::socket::State::DISABLED:
294 VLOG(1) << instanceName << ": disabled";
295 break;
296 case core::socket::State::ERROR:
297 LOG(ERROR) << instanceName << ": " << socketAddress.toString() << ": " << state.what();
298 break;
299 case core::socket::State::FATAL:
300 LOG(FATAL) << instanceName << ": " << socketAddress.toString() << ": " << state.what();
301 break;
302 }
303 });
304
305 return legacyClient;
306 }
net::in::stream::legacy::SocketClient< apps::http::SimpleSocketProtocolFactory > SocketClient
SocketClient::SocketAddress SocketAddress
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, ConfigT >::getLocalAddress(), core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT, ConfigT >::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: