ucommon
dccp.h
1 // Copyright (C) 1999-2005 Open Source Telecom Corporation.
2 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free software
18 // library without restriction. Specifically, if other files instantiate
19 // templates or use macros or inline functions from this file, or you compile
20 // this file and link it with other files to produce an executable, this
21 // file does not by itself cause the resulting executable to be covered by
22 // the GNU General Public License. This exception does not however
23 // invalidate any other reasons why the executable file might be covered by
24 // the GNU General Public License.
25 //
26 // This exception applies only to the code released under the name GNU
27 // Common C++. If you copy code from other releases into a copy of GNU
28 // Common C++, as the General Public License permits, the exception does
29 // not apply to the code that you add in this way. To avoid misleading
30 // anyone as to the status of such modified files, you must delete
31 // this exception notice from them.
32 //
33 // If you write modifications of your own for GNU Common C++, it is your choice
34 // whether to permit this exception to apply to your modifications.
35 // If you do not wish that, delete this exception notice.
36 //
37 
43 #ifndef COMMONCPP_DCCP_H_
44 #define COMMONCPP_DCCP_H_
45 
46 #include <cstdio>
47 
48 #ifndef COMMONCPP_CONFIG_H_
49 #include <commoncpp/config.h>
50 #endif
51 
52 #ifndef COMMONCPP_STRING_H_
53 #include <commoncpp/string.h>
54 #endif
55 
56 #ifndef COMMONCPP_ADDRESS_H_
57 #include <commoncpp/address.h>
58 #endif
59 
60 #ifndef COMMONCPP_SOCKET_H_
61 #include <commoncpp/socket.h>
62 #endif
63 
64 NAMESPACE_COMMONCPP
65 
92 class __EXPORT DCCPSocket : public Socket
93 {
94  union {
95  struct sockaddr_in ipv4;
96 #ifdef CCXX_IPV6
97  struct sockaddr_in6 ipv6;
98 #endif
99  } peer;
100 
101  Family family;
102 
103 public:
115  virtual bool onAccept(const IPV4Host &ia, tpport_t port);
116 #ifdef CCXX_IPV6
117  virtual bool onAccept(const IPV6Host &ia, tpport_t port);
118 #endif
119 
120  virtual IPV4Host getIPV4Sender(tpport_t *port = NULL) const;
121 
122 #ifdef CCXX_IPV6
123  virtual IPV6Host getIPV6Sender(tpport_t *port = NULL) const;
124 #endif
125 
137  DCCPSocket(const IPV4Address &bind, tpport_t port, unsigned backlog = 5);
138 #ifdef CCXX_IPV6
139  DCCPSocket(const IPV6Address &bind, tpport_t port, unsigned backlog = 5);
140 #endif
141 
151  DCCPSocket(const char *name, Family family = IPV4, unsigned backlog = 5);
152 
156  DCCPSocket(Family family = IPV4);
157 
161  DCCPSocket(DCCPSocket& server, timeout_t timeout = 0);
162 
166  void reject(void);
167 
171  void disconnect(void);
172 
176  bool setCCID(uint8_t ccid);
177 
181  int getTxCCID();
182 
186  int getRxCCID();
187 
191  size_t available();
192 
200  void connect(const IPV4Host &host, tpport_t port, timeout_t timeout = 0);
201 #ifdef CCXX_IPV6
202  void connect(const IPV6Host &host, tpport_t port, timeout_t timeout = 0);
203 #endif
204 
208  void connect(const char *name);
209 
215  inline bool isPendingConnection(timeout_t timeout = TIMEOUT_INF) /* not const -- jfc */
216  {return Socket::isPending(Socket::pendingInput, timeout);}
217 
221  virtual ~DCCPSocket();
222 };
223 
224 END_NAMESPACE
225 
226 #endif
Common C++ generic string class.
DCCP sockets are used for stream based connected sessions between two sockets.
Definition: dccp.h:92
The network name and address objects are all derived from a common IPV4Address base class...
Definition: address.h:331
This object is used to hold the actual and valid internet address of a specific host machine that wil...
Definition: address.h:542
The network name and address objects are all derived from a common IPV6Address base class...
Definition: address.h:734
unsigned long timeout_t
Typedef for millisecond timer values.
Definition: platform.h:326
socket operations.
bool isPendingConnection(timeout_t timeout=ucommon::Timer::inf)
Used to wait for pending connection requests.
Definition: dccp.h:215
Network addresses and sockets related classes.
This object is used to hold the actual and valid internet address of a specific host machine that wil...
Definition: address.h:929