UCommon
dccp.h
1 // Copyright (C) 1999-2005 Open Source Telecom Corporation.
2 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
3 // Copyright (C) 2015 Cherokees of Idaho.
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free software
19 // library without restriction. Specifically, if other files instantiate
20 // templates or use macros or inline functions from this file, or you compile
21 // this file and link it with other files to produce an executable, this
22 // file does not by itself cause the resulting executable to be covered by
23 // the GNU General Public License. This exception does not however
24 // invalidate any other reasons why the executable file might be covered by
25 // the GNU General Public License.
26 //
27 // This exception applies only to the code released under the name GNU
28 // Common C++. If you copy code from other releases into a copy of GNU
29 // Common C++, as the General Public License permits, the exception does
30 // not apply to the code that you add in this way. To avoid misleading
31 // anyone as to the status of such modified files, you must delete
32 // this exception notice from them.
33 //
34 // If you write modifications of your own for GNU Common C++, it is your choice
35 // whether to permit this exception to apply to your modifications.
36 // If you do not wish that, delete this exception notice.
37 //
38 
44 #ifndef COMMONCPP_DCCP_H_
45 #define COMMONCPP_DCCP_H_
46 
47 #include <cstdio>
48 
49 #ifndef COMMONCPP_CONFIG_H_
50 #include <commoncpp/config.h>
51 #endif
52 
53 #ifndef COMMONCPP_STRING_H_
54 #include <commoncpp/string.h>
55 #endif
56 
57 #ifndef COMMONCPP_ADDRESS_H_
58 #include <commoncpp/address.h>
59 #endif
60 
61 #ifndef COMMONCPP_SOCKET_H_
62 #include <commoncpp/socket.h>
63 #endif
64 
65 namespace ost {
66 
93 class __EXPORT DCCPSocket : public Socket
94 {
95 private:
96  union {
97  struct sockaddr_in ipv4;
98 #ifdef CCXX_IPV6
99  struct sockaddr_in6 ipv6;
100 #endif
101  } peer;
102 
103  Family family;
104 
105 public:
117  virtual bool onAccept(const IPV4Host &ia, tpport_t port);
118 #ifdef CCXX_IPV6
119  virtual bool onAccept(const IPV6Host &ia, tpport_t port);
120 #endif
121 
122  virtual IPV4Host getIPV4Sender(tpport_t *port = NULL) const;
123 
124 #ifdef CCXX_IPV6
125  virtual IPV6Host getIPV6Sender(tpport_t *port = NULL) const;
126 #endif
127 
139  DCCPSocket(const IPV4Address &bind, tpport_t port, unsigned backlog = 5);
140 #ifdef CCXX_IPV6
141  DCCPSocket(const IPV6Address &bind, tpport_t port, unsigned backlog = 5);
142 #endif
143 
153  DCCPSocket(const char *name, Family family = IPV4, unsigned backlog = 5);
154 
158  DCCPSocket(Family family = IPV4);
159 
163  DCCPSocket(DCCPSocket& server, timeout_t timeout = 0);
164 
168  void reject(void);
169 
173  void disconnect(void);
174 
178  bool setCCID(uint8_t ccid);
179 
183  int getTxCCID() const;
184 
188  int getRxCCID() const;
189 
193  size_t available() const;
194 
202  void connect(const IPV4Host &host, tpport_t port, timeout_t timeout = 0);
203 #ifdef CCXX_IPV6
204  void connect(const IPV6Host &host, tpport_t port, timeout_t timeout = 0);
205 #endif
206 
210  void connect(const char *name);
211 
217  inline bool isPendingConnection(timeout_t timeout = TIMEOUT_INF) {
218  return Socket::isPending(Socket::pendingInput, timeout);
219  }
220 
224  virtual ~DCCPSocket();
225 };
226 
227 } // namespace ost
228 
229 #endif
DCCP sockets are used for stream based connected sessions between two sockets.
Definition: dccp.h:93
This object is used to hold the actual and valid internet address of a specific host machine that wil...
Definition: address.h:578
The network name and address objects are all derived from a common IPV6Address base class.
Definition: address.h:777
This object is used to hold the actual and valid internet address of a specific host machine that wil...
Definition: address.h:981
Network addresses and sockets related classes.
bool isPendingConnection(timeout_t timeout=ucommon::Timer::inf)
Used to wait for pending connection requests.
Definition: dccp.h:217
in_port_t tpport_t
Transport Protocol Ports.
Definition: address.h:80
Common C++ generic string class.
socket operations.
The network name and address objects are all derived from a common IPV4Address base class.
Definition: address.h:362