#include <Connection.h>
Inherits Socket.
Inherited by TcpConnection, and UdpConnection.
Inheritance diagram for Connection:


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 |
Definition at line 41 of file Connection.h.
| 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().
| 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 |
| String Connection::peerIp | ( | ) | const |
| unsigned int Connection::localPort | ( | ) | const |
| unsigned int Connection::peerPort | ( | ) | const |
| int Connection::available | ( | int & | size | ) |
Definition at line 93 of file Connection.cpp.
References Socket::_socket, ERROR, MSG_SOCKET_CANNOT_GET_INFO, and OK.
| 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] |
| int Connection::setDead | ( | ) | [protected] |
Definition at line 402 of file Connection.cpp.
References Socket::_socket, EMIT, and OK.
Referenced by Poller::poll().
friend class Poller [friend] |
Reimplemented from Socket.
Reimplemented in TcpConnection, UdpConnection, and UdpServer.
Definition at line 46 of file Connection.h.
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] |
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] |
String Connection::_peerIp [protected] |
int Connection::_localPort [protected] |
int Connection::_peerPort [protected] |
1.5.1