#include <cxxtools/net/tcpsocket.h>

Inheritance diagram for cxxtools::net::TcpSocket:
cxxtools::IODevice cxxtools::Selectable cxxtools::NonCopyable tnt::GnuTlsStream tnt::OpensslStream tnt::GnuTls_iostream tnt::openssl_iostream

Public Types

enum  { INHERIT = 1, DEFER_ACCEPT = 2 }
- Public Types inherited from cxxtools::IODevice
typedef std::char_traits< char >
::pos_type 
pos_type
typedef std::char_traits< char >
::off_type 
off_type
typedef std::ios_base::seekdir SeekDir
typedef IOS_OpenMode OpenMode
- Public Types inherited from cxxtools::Selectable
enum  State { Disabled = 0, Idle = 1, Busy = 2, Avail = 3 }

Public Member Functions

 TcpSocket ()
 TcpSocket (const TcpServer &server, unsigned flags=0)
 TcpSocket (const std::string &ipaddr, unsigned short int port)
 TcpSocket (const AddrInfo &addrinfo)
 ~TcpSocket ()
std::string getSockAddr () const
std::string getPeerAddr () const
void setTimeout (std::size_t msecs)
std::size_t timeout () const
std::size_t getTimeout () const
void accept (const TcpServer &server, unsigned flags=0)
void connect (const AddrInfo &addrinfo)
void connect (const std::string &ipaddr, unsigned short int port)
bool beginConnect (const AddrInfo &addrinfo)
bool beginConnect (const std::string &ipaddr, unsigned short int port)
void endConnect ()
bool isConnected () const
int getFd () const
short poll (short events) const
virtual SelectableImpl & simpl ()
virtual IODeviceImpl & ioimpl ()
- Public Member Functions inherited from cxxtools::IODevice
virtual ~IODevice ()
 Destructor.
void beginRead (char *buffer, size_t n)
size_t endRead ()
size_t read (char *buffer, size_t n)
 Read data from I/O device.
size_t beginWrite (const char *buffer, size_t n)
size_t endWrite ()
size_t write (const char *buffer, size_t n)
 Write data to I/O device.
void cancel ()
 Cancels asynchronous reading and writing.
bool seekable () const
 Returns true if device is seekable.
pos_type seek (off_type offset, std::ios::seekdir sd)
 Move the next read position to the given offset.
size_t peek (char *buffer, size_t n)
 Read data from I/O device without consuming them.
void sync ()
 Synchronize device.
pos_type position ()
 Returns the current I/O position.
bool eof () const
 Returns if the device has reached EOF.
bool async () const
 Returns true if the device operates in asynchronous mode.
bool reading () const
bool writing () const
char * rbuf () const
size_t rbuflen () const
size_t ravail () const
const char * wbuf () const
size_t wbuflen () const
size_t wavail () const
- Public Member Functions inherited from cxxtools::Selectable
virtual ~Selectable ()
 Destructor.
void setSelector (SelectorBase *parent)
SelectorBaseselector ()
const SelectorBaseselector () const
void close ()
 Closes the I/O device.
bool wait (std::size_t msecs=WaitInfinite)
bool enabled () const
 Test if the I/O device object is enabled.
bool idle () const
bool busy () const
bool avail () const

Public Attributes

Signal< TcpSocket & > connected
Signal< TcpSocket & > closed
 Notifies when the device is closed while no reading or writing is pending.
- Public Attributes inherited from cxxtools::IODevice
Signal< IODevice & > inputReady
 Notifies about available data.
Signal< IODevice & > outputReady
 Notifies when data can be written.

Protected Member Functions

 TcpSocket (TcpSocketImpl *impl)
virtual void onClose ()
 Closes the Selector.
virtual bool onWait (std::size_t msecs)
virtual void onAttach (SelectorBase &)
virtual void onDetach (SelectorBase &)
virtual size_t onBeginRead (char *buffer, size_t n, bool &eof)
virtual size_t onEndRead (bool &eof)
virtual size_t onRead (char *buffer, size_t count, bool &eof)
 Read bytes from device.
virtual size_t onBeginWrite (const char *buffer, size_t n)
virtual size_t onEndWrite ()
virtual size_t onWrite (const char *buffer, size_t count)
 Write bytes to device.
virtual void onCancel ()
- Protected Member Functions inherited from cxxtools::IODevice
 IODevice ()
 Default Constructor.
virtual size_t onPeek (char *, size_t)
 Read data from I/O device without consuming them.
virtual bool onSeekable () const
 Returns true if device is seekable.
virtual pos_type onSeek (off_type, std::ios::seekdir)
 Move the next read position to the given offset.
virtual void onSync () const
 Synchronize device.
virtual size_t onSize () const
 Returns the size of the device.
void setEof (bool eof)
 Sets or unsets the device to eof.
void setAsync (bool async)
 Sets or unsets the device to async.
- Protected Member Functions inherited from cxxtools::Selectable
 Selectable ()
 Default Constructor.
void setEnabled (bool isEnabled)
 Sets or unsets the device enabled.
void setState (State state)
- Protected Member Functions inherited from cxxtools::NonCopyable
 NonCopyable ()

Additional Inherited Members

- Static Public Attributes inherited from cxxtools::IODevice
static const OpenMode Sync = IOS_Sync
static const OpenMode Async = IOS_Async
static const OpenMode Read = IOS_Read
static const OpenMode Write = IOS_Write
static const OpenMode AtEnd = IOS_AtEnd
static const OpenMode Append = IOS_Append
static const OpenMode Trunc = IOS_Trunc
- Protected Attributes inherited from cxxtools::IODevice
char * _rbuf
size_t _rbuflen
size_t _ravail
const char * _wbuf
size_t _wbuflen
size_t _wavail
void * _reserved

Member Enumeration Documentation

anonymous enum
Enumerator:
INHERIT 
DEFER_ACCEPT 

Constructor & Destructor Documentation

cxxtools::net::TcpSocket::TcpSocket ( )
cxxtools::net::TcpSocket::TcpSocket ( const TcpServer server,
unsigned  flags = 0 
)
cxxtools::net::TcpSocket::TcpSocket ( const std::string &  ipaddr,
unsigned short int  port 
)
cxxtools::net::TcpSocket::TcpSocket ( const AddrInfo addrinfo)
explicit
cxxtools::net::TcpSocket::~TcpSocket ( )
cxxtools::net::TcpSocket::TcpSocket ( TcpSocketImpl *  impl)
inlineprotected

Member Function Documentation

void cxxtools::net::TcpSocket::accept ( const TcpServer server,
unsigned  flags = 0 
)
bool cxxtools::net::TcpSocket::beginConnect ( const AddrInfo addrinfo)
bool cxxtools::net::TcpSocket::beginConnect ( const std::string &  ipaddr,
unsigned short int  port 
)
inline
void cxxtools::net::TcpSocket::connect ( const AddrInfo addrinfo)
void cxxtools::net::TcpSocket::connect ( const std::string &  ipaddr,
unsigned short int  port 
)
inline
void cxxtools::net::TcpSocket::endConnect ( )
int cxxtools::net::TcpSocket::getFd ( ) const
std::string cxxtools::net::TcpSocket::getPeerAddr ( ) const
std::string cxxtools::net::TcpSocket::getSockAddr ( ) const
std::size_t cxxtools::net::TcpSocket::getTimeout ( ) const
inline
virtual IODeviceImpl& cxxtools::net::TcpSocket::ioimpl ( )
virtual

Implements cxxtools::IODevice.

bool cxxtools::net::TcpSocket::isConnected ( ) const
virtual void cxxtools::net::TcpSocket::onAttach ( SelectorBase )
protectedvirtual

Implements cxxtools::Selectable.

virtual size_t cxxtools::net::TcpSocket::onBeginRead ( char *  buffer,
size_t  n,
bool &  eof 
)
protectedvirtual

Implements cxxtools::IODevice.

virtual size_t cxxtools::net::TcpSocket::onBeginWrite ( const char *  buffer,
size_t  n 
)
protectedvirtual

Implements cxxtools::IODevice.

virtual void cxxtools::net::TcpSocket::onCancel ( )
protectedvirtual

Implements cxxtools::IODevice.

virtual void cxxtools::net::TcpSocket::onClose ( )
protectedvirtual

Closes the Selector.

Implements cxxtools::Selectable.

virtual void cxxtools::net::TcpSocket::onDetach ( SelectorBase )
protectedvirtual

Implements cxxtools::Selectable.

virtual size_t cxxtools::net::TcpSocket::onEndRead ( bool &  eof)
protectedvirtual

Implements cxxtools::IODevice.

virtual size_t cxxtools::net::TcpSocket::onEndWrite ( )
protectedvirtual

Implements cxxtools::IODevice.

virtual size_t cxxtools::net::TcpSocket::onRead ( char *  buffer,
size_t  count,
bool &  eof 
)
protectedvirtual

Read bytes from device.

Implements cxxtools::IODevice.

virtual bool cxxtools::net::TcpSocket::onWait ( std::size_t  msecs)
protectedvirtual

Implements cxxtools::Selectable.

virtual size_t cxxtools::net::TcpSocket::onWrite ( const char *  buffer,
size_t  count 
)
protectedvirtual

Write bytes to device.

Implements cxxtools::IODevice.

short cxxtools::net::TcpSocket::poll ( short  events) const
void cxxtools::net::TcpSocket::setTimeout ( std::size_t  msecs)
virtual SelectableImpl& cxxtools::net::TcpSocket::simpl ( )
virtual

Implements cxxtools::Selectable.

std::size_t cxxtools::net::TcpSocket::timeout ( ) const

Member Data Documentation

Signal<TcpSocket&> cxxtools::net::TcpSocket::closed

Notifies when the device is closed while no reading or writing is pending.

Signal<TcpSocket&> cxxtools::net::TcpSocket::connected

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