SNode.C
Loading...
Searching...
No Matches
core::socket::stream Namespace Reference

Namespaces

namespace  legacy
namespace  tls
namespace  stream

Classes

class  AutoConnectControl
class  SocketContext
class  SocketConnection
class  SocketConnectionT
class  SocketContextFactory
class  SocketReader
class  SocketWriter
class  SocketConnector
class  SocketAcceptor
class  SocketClient
class  SocketServer

Functions

template<typename SocketAddress, typename PhysicalSocket, typename Config>
SocketAddress getLocalSocketAddress (PhysicalSocket &physicalSocket, Config &config)
template<typename SocketAddress, typename PhysicalSocket, typename Config>
SocketAddress getRemoteSocketAddress (PhysicalSocket &physicalSocket, Config &config)
template<typename SocketClient, typename... Args>
SocketClient Client (const std::string &instanceName, const std::function< void(typename SocketClient::Config &)> &configurator, Args &&... socketContextFactoryArgs)
template<typename SocketClient, typename... Args>
SocketClient Client (const std::string &instanceName, Args &&... socketContextFactoryArgs)
template<typename SocketServer, typename... Args>
SocketServer Server (const std::string &instanceName, const std::function< void(typename SocketServer::Config &)> &configurator, Args &&... socketContextFactoryArgs)
template<typename SocketServer, typename... Args>
SocketServer Server (const std::string &instanceName, Args &&... socketContextFactoryArgs)

Function Documentation

◆ Client() [1/2]

template<typename SocketClient, typename... Args>
SocketClient core::socket::stream::Client ( const std::string & instanceName,
Args &&... socketContextFactoryArgs )

Definition at line 417 of file SocketClient.h.

417 {
418 return SocketClient(instanceName, std::forward<Args>(socketContextFactoryArgs)...);
419 }

◆ Client() [2/2]

template<typename SocketClient, typename... Args>
SocketClient core::socket::stream::Client ( const std::string & instanceName,
const std::function< void(typename SocketClient::Config &)> & configurator,
Args &&... socketContextFactoryArgs )

Definition at line 406 of file SocketClient.h.

408 {
409 const SocketClient socketClient(instanceName, std::forward<Args>(socketContextFactoryArgs)...);
410
411 configurator(socketClient.getConfig());
412
413 return socketClient;
414 }

◆ getLocalSocketAddress()

template<typename SocketAddress, typename PhysicalSocket, typename Config>
SocketAddress core::socket::stream::getLocalSocketAddress ( PhysicalSocket & physicalSocket,
Config & config )

Definition at line 61 of file SocketConnection.hpp.

61 {
62 typename SocketAddress::SockAddr localSockAddr;
63 typename SocketAddress::SockLen localSockAddrLen = sizeof(typename SocketAddress::SockAddr);
64
65 SocketAddress localPeerAddress;
66 if (physicalSocket.getSockName(localSockAddr, localSockAddrLen) == 0) {
67 try {
68 localPeerAddress = config->Local::getSocketAddress(localSockAddr, localSockAddrLen);
69 LOG(TRACE) << config->getInstanceName() << " [" << physicalSocket.getFd() << "]" << std::setw(25)
70 << " PeerAddress (local): " << localPeerAddress.toString();
71 } catch (const typename SocketAddress::BadSocketAddress& badSocketAddress) {
72 LOG(WARNING) << config->getInstanceName() << " [" << physicalSocket.getFd() << "]" << std::setw(25)
73 << " PeerAddress (local): " << badSocketAddress.what();
74 }
75 } else {
76 PLOG(WARNING) << config->getInstanceName() << " [" << physicalSocket.getFd() << "]" << std::setw(25)
77 << " PeerAddress (local) not retrievable";
78 }
79
80 return localPeerAddress;
81 }
#define LOG(level)
Definition Logger.h:148
#define PLOG(level)
Definition Logger.h:152
virtual std::string toString(bool expanded=true) const =0

References logger::LogMessage::LogMessage(), logger::TRACE, and logger::WARNING.

Here is the call graph for this function:

◆ getRemoteSocketAddress()

template<typename SocketAddress, typename PhysicalSocket, typename Config>
SocketAddress core::socket::stream::getRemoteSocketAddress ( PhysicalSocket & physicalSocket,
Config & config )

Definition at line 84 of file SocketConnection.hpp.

84 {
85 typename SocketAddress::SockAddr remoteSockAddr;
86 typename SocketAddress::SockLen remoteSockAddrLen = sizeof(typename SocketAddress::SockAddr);
87
88 SocketAddress remotePeerAddress;
89 if (physicalSocket.getPeerName(remoteSockAddr, remoteSockAddrLen) == 0) {
90 try {
91 remotePeerAddress = config->Remote::getSocketAddress(remoteSockAddr, remoteSockAddrLen);
92 LOG(TRACE) << config->getInstanceName() << " [" << physicalSocket.getFd() << "]" << std::setw(25)
93 << " PeerAddress (remote): " << remotePeerAddress.toString();
94 } catch (const typename SocketAddress::BadSocketAddress& badSocketAddress) {
95 LOG(WARNING) << config->getInstanceName() << " [" << physicalSocket.getFd() << "]" << std::setw(25)
96 << " PeerAddress (remote): " << badSocketAddress.what();
97 }
98 } else {
99 PLOG(WARNING) << config->getInstanceName() << " [" << physicalSocket.getFd() << "]" << std::setw(25)
100 << " PeerAddress (remote) not retrievble";
101 }
102
103 return remotePeerAddress;
104 }

References logger::LogMessage::LogMessage(), logger::TRACE, and logger::WARNING.

Here is the call graph for this function:

◆ Server() [1/2]

template<typename SocketServer, typename... Args>
SocketServer core::socket::stream::Server ( const std::string & instanceName,
Args &&... socketContextFactoryArgs )

Definition at line 383 of file SocketServer.h.

383 {
384 return SocketServer(instanceName, std::forward<Args>(socketContextFactoryArgs)...);
385 }

◆ Server() [2/2]

template<typename SocketServer, typename... Args>
SocketServer core::socket::stream::Server ( const std::string & instanceName,
const std::function< void(typename SocketServer::Config &)> & configurator,
Args &&... socketContextFactoryArgs )

Definition at line 372 of file SocketServer.h.

374 {
375 const SocketServer socketServer(instanceName, std::forward<Args>(socketContextFactoryArgs)...);
376
377 configurator(socketServer.getConfig());
378
379 return socketServer;
380 }