SNode.C
Loading...
Searching...
No Matches
core::socket::stream::SocketConnection Class Referenceabstract

#include <SocketConnection.h>

Inheritance diagram for core::socket::stream::SocketConnection:
Collaboration diagram for core::socket::stream::SocketConnection:

Public Member Functions

 SocketConnection (const std::string &instanceName, int fd, const std::string &configuredServer)
 
virtual int getFd () const =0
 
void switchSocketContext (SocketContext *newSocketContext)
 
virtual void sendToPeer (const char *chunk, std::size_t chunkLen)=0
 
void sendToPeer (const std::string &data)
 
void sentToPeer (const std::vector< uint8_t > &data)
 
void sentToPeer (const std::vector< char > &data)
 
virtual bool streamToPeer (core::pipe::Source *source)=0
 
virtual void streamEof ()=0
 
virtual std::size_t readFromPeer (char *chunk, std::size_t chunkLen)=0
 
virtual void shutdownRead ()=0
 
virtual void shutdownWrite (bool forceClose)=0
 
const std::string & getInstanceName () const
 
const std::string & getConnectionName () const
 
const std::string & getConfiguredServer () const
 
virtual const core::socket::SocketAddressgetLocalAddress () const =0
 
virtual const core::socket::SocketAddressgetRemoteAddress () const =0
 
virtual void close ()=0
 
virtual void setTimeout (const utils::Timeval &timeout)=0
 

Protected Member Functions

virtual ~SocketConnection ()
 
void setSocketContext (SocketContext *socketContext)
 
void connectSocketContext (const std::shared_ptr< SocketContextFactory > &socketContextFactory)
 
void disconnectCurrentSocketContext ()
 

Protected Attributes

core::socket::stream::SocketContextsocketContext = nullptr
 
core::socket::stream::SocketContextnewSocketContext = nullptr
 
std::string instanceName
 
std::string connectionName
 
std::string configuredServer
 

Detailed Description

Definition at line 75 of file SocketConnection.h.

Constructor & Destructor Documentation

◆ SocketConnection()

core::socket::stream::SocketConnection::SocketConnection ( const std::string & instanceName,
int fd,
const std::string & configuredServer )

Definition at line 55 of file SocketConnection.cpp.

References SocketConnection().

Referenced by SocketConnection().

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

◆ ~SocketConnection()

core::socket::stream::SocketConnection::~SocketConnection ( )
protectedvirtual

Definition at line 61 of file SocketConnection.cpp.

61 {
62 }

Member Function Documentation

◆ close()

virtual void core::socket::stream::SocketConnection::close ( )
pure virtual

Implemented in core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >.

Referenced by connectSocketContext().

Here is the caller graph for this function:

◆ connectSocketContext()

void core::socket::stream::SocketConnection::connectSocketContext ( const std::shared_ptr< SocketContextFactory > & socketContextFactory)
protected

Definition at line 102 of file SocketConnection.cpp.

102 {
103 SocketContext* socketContext = socketContextFactory->create(this);
104
105 if (socketContext != nullptr) {
106 LOG(DEBUG) << connectionName << ": Creating SocketContext successful";
108 } else {
109 LOG(ERROR) << connectionName << ": Failed creating SocketContext";
110 close();
111 }
112 }
core::socket::stream::SocketContext * socketContext
void setSocketContext(SocketContext *socketContext)

References close().

Here is the call graph for this function:

◆ disconnectCurrentSocketContext()

void core::socket::stream::SocketConnection::disconnectCurrentSocketContext ( )
protected

Definition at line 114 of file SocketConnection.cpp.

114 {
115 if (socketContext != nullptr) {
117 delete socketContext;
118
119 LOG(DEBUG) << connectionName << ": SocketContext disconnected";
120 }
121 }

Referenced by core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >::onReceivedFromPeer(), and core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >::unobservedEvent().

Here is the caller graph for this function:

◆ getConfiguredServer()

const std::string & core::socket::stream::SocketConnection::getConfiguredServer ( ) const

Definition at line 98 of file SocketConnection.cpp.

98 {
99 return configuredServer;
100 }

◆ getConnectionName()

const std::string & core::socket::stream::SocketConnection::getConnectionName ( ) const

Definition at line 94 of file SocketConnection.cpp.

94 {
95 return connectionName;
96 }

◆ getFd()

virtual int core::socket::stream::SocketConnection::getFd ( ) const
pure virtual

◆ getInstanceName()

const std::string & core::socket::stream::SocketConnection::getInstanceName ( ) const

Definition at line 90 of file SocketConnection.cpp.

90 {
91 return instanceName;
92 }

◆ getLocalAddress()

virtual const core::socket::SocketAddress & core::socket::stream::SocketConnection::getLocalAddress ( ) const
pure virtual

◆ getRemoteAddress()

virtual const core::socket::SocketAddress & core::socket::stream::SocketConnection::getRemoteAddress ( ) const
pure virtual

◆ readFromPeer()

virtual std::size_t core::socket::stream::SocketConnection::readFromPeer ( char * chunk,
std::size_t chunkLen )
pure virtual

◆ sendToPeer() [1/2]

virtual void core::socket::stream::SocketConnection::sendToPeer ( const char * chunk,
std::size_t chunkLen )
pure virtual

◆ sendToPeer() [2/2]

void core::socket::stream::SocketConnection::sendToPeer ( const std::string & data)

Definition at line 78 of file SocketConnection.cpp.

78 {
79 sendToPeer(data.data(), data.size());
80 }
virtual void sendToPeer(const char *chunk, std::size_t chunkLen)=0

◆ sentToPeer() [1/2]

void core::socket::stream::SocketConnection::sentToPeer ( const std::vector< char > & data)

Definition at line 86 of file SocketConnection.cpp.

86 {
87 sendToPeer(data.data(), data.size());
88 }

◆ sentToPeer() [2/2]

void core::socket::stream::SocketConnection::sentToPeer ( const std::vector< uint8_t > & data)

Definition at line 82 of file SocketConnection.cpp.

82 {
83 sendToPeer(reinterpret_cast<const char*>(data.data()), data.size());
84 }

◆ setSocketContext()

void core::socket::stream::SocketConnection::setSocketContext ( SocketContext * socketContext)
protected

Definition at line 68 of file SocketConnection.cpp.

68 {
69 if (socketContext != nullptr) { // Perform a pending SocketContextSwitch
70 LOG(DEBUG) << connectionName << ": Connecting SocketContext";
73 } else {
74 LOG(ERROR) << connectionName << ": Connecting SocketContext failed: no new SocketContext";
75 }
76 }

◆ setTimeout()

virtual void core::socket::stream::SocketConnection::setTimeout ( const utils::Timeval & timeout)
pure virtual

◆ shutdownRead()

virtual void core::socket::stream::SocketConnection::shutdownRead ( )
pure virtual

◆ shutdownWrite()

virtual void core::socket::stream::SocketConnection::shutdownWrite ( bool forceClose)
pure virtual

◆ streamEof()

virtual void core::socket::stream::SocketConnection::streamEof ( )
pure virtual

◆ streamToPeer()

virtual bool core::socket::stream::SocketConnection::streamToPeer ( core::pipe::Source * source)
pure virtual

◆ switchSocketContext()

void core::socket::stream::SocketConnection::switchSocketContext ( SocketContext * newSocketContext)

Definition at line 64 of file SocketConnection.cpp.

64 {
66 }
core::socket::stream::SocketContext * newSocketContext

Member Data Documentation

◆ configuredServer

std::string core::socket::stream::SocketConnection::configuredServer
protected

Definition at line 125 of file SocketConnection.h.

◆ connectionName

std::string core::socket::stream::SocketConnection::connectionName
protected

Definition at line 123 of file SocketConnection.h.

◆ instanceName

std::string core::socket::stream::SocketConnection::instanceName
protected

Definition at line 122 of file SocketConnection.h.

◆ newSocketContext

core::socket::stream::SocketContext* core::socket::stream::SocketConnection::newSocketContext = nullptr
protected

Definition at line 120 of file SocketConnection.h.

◆ socketContext

core::socket::stream::SocketContext* core::socket::stream::SocketConnection::socketContext = nullptr
protected

Definition at line 119 of file SocketConnection.h.


The documentation for this class was generated from the following files: