libcsdbg  1.28
C++ exception (and generic) stack trace debug library
tcpsockbuf.hpp
Go to the documentation of this file.
1 #ifndef _CSDBG_TCPSOCKBUF
2 #define _CSDBG_TCPSOCKBUF 1
3 
10 #include "./streambuf.hpp"
11 
12 namespace csdbg {
13 
34 class tcpsockbuf: virtual public streambuf
35 {
36 protected:
37 
38  /* Protected variables */
39 
44 public:
45 
46  /* Constructors, copy constructors and destructor */
47 
48  explicit tcpsockbuf(const i8*, i32 = g_ldp_port);
49 
50  tcpsockbuf(const tcpsockbuf&);
51 
52  virtual ~tcpsockbuf();
53 
54  virtual tcpsockbuf* clone() const;
55 
56 
57  /* Accessor methods */
58 
59  virtual const i8* address() const;
60 
61  virtual i32 port() const;
62 
63  virtual bool is_connected() const;
64 
65 
66  /* Operator overloading methods */
67 
68  virtual tcpsockbuf& operator=(const tcpsockbuf&);
69 
70 
71  /* Generic methods */
72 
73  virtual tcpsockbuf& open();
74 
75  virtual tcpsockbuf& flush();
76 
77  virtual tcpsockbuf& sync() const;
78 
79  virtual tcpsockbuf& set_option(i32, const void*, u32);
80 
81  virtual tcpsockbuf& shutdown(i32) const;
82 };
83 
84 }
85 
86 #endif
87 
This abstract class is the base for all buffered output stream types (for files, sockets, serial interfaces e.t.c)
Definition: streambuf.hpp:37
char i8
8-bit signed integer
Definition: config.hpp:72
i8 * m_address
Peer IP address (numerical, IPv4)
Definition: tcpsockbuf.hpp:40
i32 m_port
Peer TCP port.
Definition: tcpsockbuf.hpp:42
Class csdbg::streambuf definition.
tcpsockbuf(const i8 *, i32=g_ldp_port)
Object constructor.
Definition: tcpsockbuf.cpp:24
virtual ~tcpsockbuf()
Object destructor.
Definition: tcpsockbuf.cpp:74
virtual const i8 * address() const
Get the peer IP address.
Definition: tcpsockbuf.cpp:100
virtual tcpsockbuf & sync() const
Commit cached data to the network.
Definition: tcpsockbuf.cpp:244
virtual tcpsockbuf & open()
Connect the socket to its peer.
Definition: tcpsockbuf.cpp:170
A buffered TCP/IP socket output stream.
Definition: tcpsockbuf.hpp:34
virtual tcpsockbuf & shutdown(i32) const
Shutdown one or both socket channels.
Definition: tcpsockbuf.cpp:299
virtual bool is_connected() const
Check if the socket is connected to its peer.
Definition: tcpsockbuf.cpp:122
virtual tcpsockbuf & operator=(const tcpsockbuf &)
Assignment operator.
Definition: tcpsockbuf.cpp:138
virtual tcpsockbuf & set_option(i32, const void *, u32)
Set a socket option (applies only for the SOL_SOCKET ioctl level)
Definition: tcpsockbuf.cpp:265
unsigned int u32
32-bit unsigned integer
Definition: config.hpp:102
int i32
32-bit signed integer
Definition: config.hpp:82
static const i32 g_ldp_port
LDP service port.
Definition: config.hpp:210
virtual i32 port() const
Get the peer TCP port.
Definition: tcpsockbuf.cpp:111
virtual tcpsockbuf & flush()
Flush the buffered data to the socket.
Definition: tcpsockbuf.cpp:220
virtual tcpsockbuf * clone() const
Object virtual copy constructor.
Definition: tcpsockbuf.cpp:89