Connection Class Reference

#include <Connection.h>

Inherits Socket.

Inherited by TcpConnection, and UdpConnection.

Inheritance diagram for Connection:

Inheritance graph
[legend]
Collaboration diagram for Connection:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Connection (const int socket, struct sockaddr_in *addr)
 Connection ()
virtual ~Connection ()
int shutdown (const int how)
int close ()
String localIp () const
String peerIp () const
unsigned int localPort () const
unsigned int peerPort () const
int available (int &size)
int read (char *buffer, const unsigned int size, const unsigned int triesNum=0)
int readAvailable (char *buffer, const unsigned int maxSize, int &actuallyRead)
int readLn (String &buffer, const unsigned int maxSize=LIMIT_CSTRING_SIZE, const unsigned int triesNum=CONNECTION_TRIES_NUM_DEFAULT)
int write (const char *data, const unsigned int size, int &actuallyWritten)
int writeStr (const String &str)
int writeStr (char *str)
int writeLn (char *data, const char *eol=String::eol())
int vprintf (const char *format, va_list ap)
int printf (const char *format,...) __attribute__((format(printf
int int isAlive (bool &yes)
int clear ()
 SIGNAL (dataReady)
 SIGNAL (closed)
 SIGNAL (dead)

Static Public Member Functions

static int setAddress (const char *host, const char *service, const char *protocol, struct sockaddr_in *sap)
static int localIp (String &ip)

Protected Member Functions

int setup (const int socket, struct sockaddr_in *addr)
int setDataReady ()
int setDead ()

Protected Attributes

String _host
String _service
sockaddr_in _local
sockaddr_in _peer
String _localIp
String _peerIp
int _localPort
int _peerPort

Friends

class Poller

Detailed Description

Definition at line 41 of file Connection.h.


Constructor & Destructor Documentation

Connection::Connection ( const int  socket,
struct sockaddr_in *  addr 
)

Definition at line 28 of file Connection.cpp.

References ERROR_BACKTRACE(), FAILED(), Support::failure(), and setup().

Connection::Connection (  ) 

Definition at line 36 of file Connection.cpp.

Connection::~Connection (  )  [virtual]

Definition at line 40 of file Connection.cpp.

References Socket::_socket, close(), CORE(), ERROR_BACKTRACE(), FAILED(), and shutdown().


Member Function Documentation

int Connection::shutdown ( const int  how  ) 

Definition at line 54 of file Connection.cpp.

References Socket::_socket, ERROR, MSG_SOCKET_CANNOT_SHUTDOWN, and OK.

Referenced by ~Connection().

int Connection::close (  ) 

Definition at line 62 of file Connection.cpp.

References Socket::_socket, EMIT, ERROR, MSG_SOCKET_CANNOT_CLOSE, and OK.

Referenced by localIp(), and ~Connection().

String Connection::localIp (  )  const

Definition at line 73 of file Connection.cpp.

References _localIp.

Referenced by Syslog::log().

String Connection::peerIp (  )  const

Definition at line 78 of file Connection.cpp.

References _peerIp.

unsigned int Connection::localPort (  )  const

Definition at line 83 of file Connection.cpp.

References _localPort.

unsigned int Connection::peerPort (  )  const

Definition at line 88 of file Connection.cpp.

References _peerPort.

int Connection::available ( int &  size  ) 

Definition at line 93 of file Connection.cpp.

References Socket::_socket, ERROR, MSG_SOCKET_CANNOT_GET_INFO, and OK.

Referenced by clear(), and read().

int Connection::read ( char *  buffer,
const unsigned int  size,
const unsigned int  triesNum = 0 
)

Definition at line 101 of file Connection.cpp.

References _peer, Socket::_socket, available(), CONNECTION_SLEEP_TIME, ERROR, ERROR_BACKTRACE(), FAILED(), MSG_SOCKET_CANNOT_READ, and OK.

Referenced by Telnet::parse().

int Connection::readAvailable ( char *  buffer,
const unsigned int  maxSize,
int &  actuallyRead 
)

Definition at line 136 of file Connection.cpp.

References _peer, Socket::_socket, ERROR, MSG_SOCKET_CANNOT_READ, and OK.

int Connection::readLn ( String buffer,
const unsigned int  maxSize = LIMIT_CSTRING_SIZE,
const unsigned int  triesNum = CONNECTION_TRIES_NUM_DEFAULT 
)

Definition at line 147 of file Connection.cpp.

References _peer, Socket::_socket, CONNECTION_SLEEP_TIME, ERROR, MSG_SOCKET_CANNOT_READ, and OK.

Referenced by Inetd::authorize().

int Connection::write ( const char *  data,
const unsigned int  size,
int &  actuallyWritten 
)

Definition at line 185 of file Connection.cpp.

References _peer, Socket::_socket, ERROR, MSG_SOCKET_CANNOT_WRITE, and OK.

Referenced by Telnet::iac(), FShGetLine::onPutc(), FShGetLine::onPuts(), FShGetLine::onTab(), writeLn(), and writeStr().

int Connection::writeStr ( const String str  ) 

Definition at line 193 of file Connection.cpp.

References CSTRING(), ERROR, ERROR_BACKTRACE(), FAILED(), MSG_SOCKET_CANNOT_WRITE, OK, and write().

Referenced by Inetd::authorize(), FShGetLine::FShGetLine(), Syslog::log(), FShGetLine::onOutput(), FShGetLine::onTab(), and vprintf().

int Connection::writeStr ( char *  str  ) 

Definition at line 209 of file Connection.cpp.

References ERROR, ERROR_BACKTRACE(), FAILED(), MSG_SOCKET_CANNOT_WRITE, OK, and write().

int Connection::writeLn ( char *  data,
const char *  eol = String::eol() 
)

Definition at line 225 of file Connection.cpp.

References String::eol(), ERROR, ERROR_BACKTRACE(), FAILED(), MSG_SOCKET_CANNOT_WRITE, OK, and write().

int Connection::vprintf ( const char *  format,
va_list  ap 
)

Definition at line 252 of file Connection.cpp.

References ERROR_BACKTRACE(), FAILED(), OK, String::vsprintf(), and writeStr().

Referenced by printf().

int Connection::printf ( const char *  format,
  ... 
)

Definition at line 264 of file Connection.cpp.

References ERROR_BACKTRACE(), FAILED(), OK, and vprintf().

int Connection::isAlive ( bool yes  ) 

Definition at line 279 of file Connection.cpp.

References _peer, Socket::_socket, and OK.

Referenced by Poller::poll().

int Connection::clear (  ) 

Definition at line 292 of file Connection.cpp.

References _peer, Socket::_socket, available(), ERROR_BACKTRACE(), FAILED(), LIMIT_CSTRING_SIZE, and OK.

Referenced by Inetd::authorize().

int Connection::setAddress ( const char *  host,
const char *  service,
const char *  protocol,
struct sockaddr_in *  sap 
) [static]

Definition at line 317 of file Connection.cpp.

References ERROR, MSG_SOCKET_UNKNOWN_HOST, MSG_SOCKET_UNKNOWN_SERVICE, and OK.

Referenced by TcpConnection::TcpConnection(), TcpServer::TcpServer(), and UdpConnection::UdpConnection().

int Connection::localIp ( String ip  )  [static]

Definition at line 349 of file Connection.cpp.

References close(), CONNECTION_DEFAULT_INT_NAME, ERROR, MSG_SOCKET_CANNOT_CLOSE, MSG_SOCKET_CANNOT_CREATE, MSG_SOCKET_CANNOT_GET_INFO, OK, and Socket::socket().

Connection::SIGNAL ( dataReady   ) 

Connection::SIGNAL ( closed   ) 

Connection::SIGNAL ( dead   ) 

int Connection::setup ( const int  socket,
struct sockaddr_in *  addr 
) [protected]

Definition at line 375 of file Connection.cpp.

References _local, _localIp, _localPort, _peer, _peerIp, _peerPort, Socket::_socket, CORE(), ERROR_BACKTRACE(), FAILED(), and OK.

Referenced by Connection(), TcpConnection::TcpConnection(), and UdpConnection::UdpConnection().

int Connection::setDataReady (  )  [protected]

Definition at line 396 of file Connection.cpp.

References EMIT, and OK.

Referenced by Poller::poll().

int Connection::setDead (  )  [protected]

Definition at line 402 of file Connection.cpp.

References Socket::_socket, EMIT, and OK.

Referenced by Poller::poll().


Friends And Related Function Documentation

friend class Poller [friend]

Reimplemented from Socket.

Reimplemented in TcpConnection, UdpConnection, and UdpServer.

Definition at line 46 of file Connection.h.


Member Data Documentation

String Connection::_host [protected]

Definition at line 93 of file Connection.h.

String Connection::_service [protected]

Definition at line 94 of file Connection.h.

struct sockaddr_in Connection::_local [protected]

Definition at line 95 of file Connection.h.

Referenced by setup(), and UdpServer::UdpServer().

struct sockaddr_in Connection::_peer [protected]

Definition at line 96 of file Connection.h.

Referenced by clear(), TcpConnection::connect(), isAlive(), read(), readAvailable(), readLn(), setup(), and write().

String Connection::_localIp [protected]

Definition at line 97 of file Connection.h.

Referenced by localIp(), and setup().

String Connection::_peerIp [protected]

Definition at line 97 of file Connection.h.

Referenced by peerIp(), and setup().

int Connection::_localPort [protected]

Definition at line 98 of file Connection.h.

Referenced by localPort(), and setup().

int Connection::_peerPort [protected]

Definition at line 98 of file Connection.h.

Referenced by peerPort(), and setup().


The documentation for this class was generated from the following files:
Generated on Thu Sep 6 20:13:33 2007 for Pylon Application Platform by  doxygen 1.5.1