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 53 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 33 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 39 of file SocketConnection.cpp.

39 {
40 }

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 80 of file SocketConnection.cpp.

80 {
81 SocketContext* socketContext = socketContextFactory->create(this);
82
83 if (socketContext != nullptr) {
84 LOG(DEBUG) << connectionName << ": Creating SocketContext successful";
86 } else {
87 LOG(ERROR) << connectionName << ": Failed creating SocketContext";
88 close();
89 }
90 }
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 92 of file SocketConnection.cpp.

92 {
93 if (socketContext != nullptr) {
95 delete socketContext;
96
97 LOG(DEBUG) << connectionName << ": SocketContext disconnected";
98 }
99 }

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 76 of file SocketConnection.cpp.

76 {
77 return configuredServer;
78 }

◆ getConnectionName()

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

Definition at line 72 of file SocketConnection.cpp.

72 {
73 return connectionName;
74 }

◆ getFd()

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

◆ getInstanceName()

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

Definition at line 68 of file SocketConnection.cpp.

68 {
69 return instanceName;
70 }

◆ 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 56 of file SocketConnection.cpp.

56 {
57 sendToPeer(data.data(), data.size());
58 }
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 64 of file SocketConnection.cpp.

64 {
65 sendToPeer(data.data(), data.size());
66 }

◆ sentToPeer() [2/2]

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

Definition at line 60 of file SocketConnection.cpp.

60 {
61 sendToPeer(reinterpret_cast<const char*>(data.data()), data.size());
62 }

◆ setSocketContext()

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

Definition at line 46 of file SocketConnection.cpp.

46 {
47 if (socketContext != nullptr) { // Perform a pending SocketContextSwitch
48 LOG(DEBUG) << connectionName << ": Connecting SocketContext";
51 } else {
52 LOG(ERROR) << connectionName << ": Connecting SocketContext failed: no new SocketContext";
53 }
54 }

◆ 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 42 of file SocketConnection.cpp.

42 {
44 }
core::socket::stream::SocketContext * newSocketContext

Member Data Documentation

◆ configuredServer

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

Definition at line 103 of file SocketConnection.h.

◆ connectionName

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

Definition at line 101 of file SocketConnection.h.

◆ instanceName

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

Definition at line 100 of file SocketConnection.h.

◆ newSocketContext

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

Definition at line 98 of file SocketConnection.h.

◆ socketContext

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

Definition at line 97 of file SocketConnection.h.


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