Adbase
Adinf C++ base library V2
adbase::TcpConnection Class Reference

#include <TcpConnection.hpp>

Inherits enable_shared_from_this< TcpConnection >.

Public Member Functions

 TcpConnection (EventBasePtr &base, int sockfd, const InetAddress &localAddr, const InetAddress &peerAddr, int connId, const RemoveConnectionCallback &removeCb)
 
 ~TcpConnection ()
 
const InetAddresslocalAddress () const
 
const InetAddresspeerAddress () const
 
void init ()
 
void eventCallback (short events)
 
void readCallback ()
 
void writeCallback ()
 
bool getTcpInfo (struct tcp_info *) const
 
std::string getTcpInfoString () const
 
void send (const void *message, size_t len)
 
void send (std::string &message)
 
void shutdown ()
 
void setTcpNoDelay (bool on)
 
void setContext (void *data)
 
void * getContext ()
 
bool connected () const
 
bool disconnected () const
 
void setMessageCallback (const MessageCallback &cb)
 
void setWriteCompleteCallback (const WriteCompleteCallback &cb)
 
void setConnectionCookiePrefix (const ConnectionCookiePrefix &cp)
 
const std::string getCookie ()
 

Detailed Description

Definition at line 26 of file TcpConnection.hpp.

Constructor & Destructor Documentation

adbase::TcpConnection::TcpConnection ( EventBasePtr base,
int  sockfd,
const InetAddress localAddr,
const InetAddress peerAddr,
int  connId,
const RemoveConnectionCallback removeCb 
)

Definition at line 52 of file TcpConnection.cpp.

References adbase::Socket::fd(), and adbase::Socket::setKeepAlive().

adbase::TcpConnection::~TcpConnection ( )

Definition at line 79 of file TcpConnection.cpp.

References LOG_TRACE.

Member Function Documentation

bool adbase::TcpConnection::connected ( ) const
inline

Definition at line 58 of file TcpConnection.hpp.

bool adbase::TcpConnection::disconnected ( ) const
inline

Definition at line 62 of file TcpConnection.hpp.

void adbase::TcpConnection::eventCallback ( short  events)

Definition at line 156 of file TcpConnection.cpp.

References LOG_DEBUG, LOG_ERROR, and LOG_TRACE.

Referenced by adbase::detail::eventCallback().

void* adbase::TcpConnection::getContext ( )
inline

Definition at line 54 of file TcpConnection.hpp.

const std::string adbase::TcpConnection::getCookie ( )

Definition at line 143 of file TcpConnection.cpp.

bool adbase::TcpConnection::getTcpInfo ( struct tcp_info *  tcpi) const

Definition at line 86 of file TcpConnection.cpp.

References adbase::Socket::getTcpInfo().

std::string adbase::TcpConnection::getTcpInfoString ( ) const

Definition at line 93 of file TcpConnection.cpp.

References adbase::Socket::getTcpInfoString().

void adbase::TcpConnection::init ( )
const InetAddress& adbase::TcpConnection::localAddress ( ) const
inline

Definition at line 32 of file TcpConnection.hpp.

const InetAddress& adbase::TcpConnection::peerAddress ( ) const
inline
void adbase::TcpConnection::readCallback ( )

Definition at line 174 of file TcpConnection.cpp.

References LOG_TRACE, and adbase::Timestamp::now().

Referenced by adbase::detail::readCallback().

void adbase::TcpConnection::send ( const void *  message,
size_t  len 
)

Definition at line 103 of file TcpConnection.cpp.

References LOG_ERROR.

Referenced by send().

void adbase::TcpConnection::send ( std::string &  message)

Definition at line 117 of file TcpConnection.cpp.

References send().

void adbase::TcpConnection::setConnectionCookiePrefix ( const ConnectionCookiePrefix cp)
inline

Definition at line 72 of file TcpConnection.hpp.

void adbase::TcpConnection::setContext ( void *  data)
inline

Definition at line 50 of file TcpConnection.hpp.

void adbase::TcpConnection::setMessageCallback ( const MessageCallback cb)
inline

Definition at line 66 of file TcpConnection.hpp.

void adbase::TcpConnection::setTcpNoDelay ( bool  on)

Definition at line 136 of file TcpConnection.cpp.

References adbase::Socket::setTcpNoDelay().

void adbase::TcpConnection::setWriteCompleteCallback ( const WriteCompleteCallback cb)
inline

Definition at line 69 of file TcpConnection.hpp.

void adbase::TcpConnection::shutdown ( )

Definition at line 124 of file TcpConnection.cpp.

References LOG_DEBUG, and adbase::Socket::shutdownWrite().

void adbase::TcpConnection::writeCallback ( )

Definition at line 183 of file TcpConnection.cpp.

References LOG_DEBUG, LOG_TRACE, and adbase::Socket::shutdownWrite().

Referenced by adbase::detail::writeCallback().


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