libassa  3.5.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IPv4Socket.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //------------------------------------------------------------------------------
3 // IPv4Socket.h
4 //------------------------------------------------------------------------------
5 // Copyright (c) 1998 by Vladislav Grinchenko
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Library General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
11 //------------------------------------------------------------------------------
12 #ifndef IPV4_SOCKET_Hh
13 #define IPV4_SOCKET_Hh
14 
15 #include "assa/Socket.h"
16 #include "assa/Socketbuf.h"
17 
24 namespace ASSA {
25 class IPv4Socket : public Socket
26 {
27 public:
29  static const int MAXTCPBUFSZ;
30 
33  : m_path (0), m_rdbuf (new Socketbuf (this)) {
34  trace_with_mask("IPv4Socket::IPv4Socket()",SOCKTRACE);
35  }
36 
40  IPv4Socket(const handler_t fd_)
41  : m_path (0), m_rdbuf (new Socketbuf (this))
42  {
43  trace_with_mask("IPv4Socket::IPv4Socket(fd_)",SOCKTRACE);
44 
45  m_fd = fd_; // inherited from the parent class
46  }
47 
50  {
51  trace_with_mask("IPv4Socket::~IPv4Socket",SOCKTRACE);
52  this->close ();
53 
54  if (m_rdbuf != 0) {
55  delete m_rdbuf;
56  }
57  }
58 
64  IPv4Socket* clone () const;
65 
66 
74  bool open(const int domain_);
75 
79  bool close();
80 
90  bool connect(const Address& address_);
91 
99  virtual bool bind (const Address& my_address_);
100 
111  IPv4Socket* accept ();
112 
123  int read (char* buf_, const unsigned int size_);
124 
131  int write (const char* buf_, const unsigned int size_);
132 
133 
135  handler_t getHandler () const { return m_fd; }
136 
138  const int getDomain () const { return m_type; }
139 
146  virtual Streambuf* rdbuf () { return m_rdbuf; }
147 
155  virtual Streambuf* rdbuf (Streambuf* sb_);
156 
162  virtual int in_avail () const { return m_rdbuf->in_avail (); }
163 
164 private:
165  // No copying
166  IPv4Socket (const IPv4Socket&);
168 
169 private:
171 
173  char* m_path;
174 
177 };
178 
179 } // end namespace ASSA
180 
181 #endif // IPV4_SOCKET_Hh
182 
183 
184