libcsdbg
1.28
C++ exception (and generic) stack trace debug library
|
A buffered TCP/IP socket output stream. More...
#include <tcpsockbuf.hpp>
Public Member Functions | |
tcpsockbuf (const i8 *, i32=g_ldp_port) | |
Object constructor. More... | |
tcpsockbuf (const tcpsockbuf &) | |
Object copy constructor. More... | |
virtual | ~tcpsockbuf () |
Object destructor. More... | |
virtual tcpsockbuf * | clone () const |
Object virtual copy constructor. More... | |
virtual const i8 * | address () const |
Get the peer IP address. More... | |
virtual i32 | port () const |
Get the peer TCP port. More... | |
virtual bool | is_connected () const |
Check if the socket is connected to its peer. More... | |
virtual tcpsockbuf & | operator= (const tcpsockbuf &) |
Assignment operator. More... | |
virtual tcpsockbuf & | open () |
Connect the socket to its peer. More... | |
virtual tcpsockbuf & | flush () |
Flush the buffered data to the socket. More... | |
virtual tcpsockbuf & | sync () const |
Commit cached data to the network. More... | |
virtual tcpsockbuf & | set_option (i32, const void *, u32) |
Set a socket option (applies only for the SOL_SOCKET ioctl level) More... | |
virtual tcpsockbuf & | shutdown (i32) const |
Shutdown one or both socket channels. More... | |
Public Member Functions inherited from csdbg::streambuf | |
streambuf () | |
Object default constructor. More... | |
streambuf (const streambuf &) | |
Object copy constructor. More... | |
virtual | ~streambuf ()=0 |
To be implemented. More... | |
virtual i32 | handle () const |
Get the handle. More... | |
virtual bool | is_opened () const |
Check if the stream is opened for output. More... | |
virtual streambuf & | operator= (const streambuf &) |
Assignment operator. More... | |
virtual streambuf & | close () |
Close the stream. More... | |
virtual streambuf & | lock () const |
Lock the stream (exclusively) More... | |
virtual streambuf & | unlock () const |
Unlock the stream. More... | |
virtual streambuf & | header () |
Append LDP headers to the buffer. More... | |
Public Member Functions inherited from csdbg::string | |
string (u32=0) | |
Object constructor. More... | |
string (const i8 *,...) | |
Object constructor. More... | |
string (const string &) | |
Object copy constructor. More... | |
virtual | ~string () |
Object destructor. More... | |
virtual const i8 * | cstr () const |
Get the C-string equivalent. More... | |
virtual u32 | length () const |
Get the character count. More... | |
virtual u32 | bufsize () const |
Get the buffer size. More... | |
virtual i8 & | at (u32) |
Get/set the character at an offset. More... | |
virtual string & | set (const i8 *,...) |
Fill with a printf-style format C-string expanded with the values of a variable argument list. More... | |
virtual string & | set (const string &) |
Copy a string. More... | |
virtual string & | operator= (const string &) |
Assignment operator. More... | |
virtual string & | operator+= (const string &) |
Compound addition-assignment operator (append) More... | |
virtual i8 & | operator[] (u32) |
Subscript operator. More... | |
virtual u32 | available () const |
Get the available buffer size, the number of characters that can be appended without reallocation. More... | |
virtual string & | shred (u8=0) |
Fill the whole buffer with a constant byte. More... | |
virtual string & | clear () |
Clear contents. More... | |
virtual string & | append (const string &) |
Append a string. More... | |
virtual string & | append (const i8 *,...) |
Append a printf-style format C-string expanded with the values of a variable argument list. More... | |
virtual string & | append (i8) |
Append a character. More... | |
virtual i32 | cmp (const string &, bool=false) const |
Compare to another string. More... | |
virtual bool | match (const string &, bool=false) const |
Match against a POSIX extended regular expression. More... | |
virtual string & | trim (i32=0) |
Remove leading and/or trailing whitespace characters. More... | |
virtual string & | insert (u32, const string &) |
Insert a string at a specified position. More... | |
virtual string & | insert (u32, const i8 *,...) |
Insert a printf-style format C-string expanded with the values of a variable argument list, at a specified position. More... | |
virtual chain< string > * | split (const string &, bool=true, bool=false) const |
Tokenize using a POSIX extended regular expression. More... | |
Public Member Functions inherited from csdbg::object | |
virtual | ~object ()=0 |
To be implemented. More... | |
virtual const i8 * | class_name () const |
Query the class name of an object descending from csdbg::object. More... | |
Protected Attributes | |
i8 * | m_address |
Peer IP address (numerical, IPv4) More... | |
i32 | m_port |
Peer TCP port. More... | |
Protected Attributes inherited from csdbg::streambuf | |
i32 | m_handle |
Stream handle (descriptor) More... | |
Protected Attributes inherited from csdbg::string | |
i8 * | m_data |
String data. More... | |
u32 | m_length |
Character count. More... | |
u32 | m_size |
Buffer size. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from csdbg::string | |
virtual string & | memalign (u32, bool=false) |
Allocate aligned memory, mandate a minimum buffer size. More... | |
virtual string & | format (const i8 *, va_list) |
Fill with a printf-style format C-string expanded with the values of a variable argument list. More... | |
A buffered TCP/IP socket output stream.
A tcpsockbuf object is a buffered TCP/IP client socket, designed specifically to implement the client side of LDP, or any other unidirectional application protocol (write only). The class currently supports only IPv4 addresses. This class is not thread safe, the caller must implement thread synchronization, nevertheless basic stream locking methods are inherited from csdbg::streambuf
Add domain name lookup (getaddrinfo will also resolve IPv4 vs IPv6)
Implement connection drop detection (SO_KEEPALIVE, SIGPIPE)
Fine tune socket options (buffer size, linger, no-delay e.t.c)
Stream locking
TCP_NODELAY option or other means to flush cached network data
Exploit shutdown on close
Definition at line 34 of file tcpsockbuf.hpp.