00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00043 #ifndef COMMONCPP_DCCP_H_
00044 #define COMMONCPP_DCCP_H_
00045
00046 #include <cstdio>
00047
00048 #ifndef COMMONCPP_CONFIG_H_
00049 #include <commoncpp/config.h>
00050 #endif
00051
00052 #ifndef COMMONCPP_STRING_H_
00053 #include <commoncpp/string.h>
00054 #endif
00055
00056 #ifndef COMMONCPP_ADDRESS_H_
00057 #include <commoncpp/address.h>
00058 #endif
00059
00060 #ifndef COMMONCPP_SOCKET_H_
00061 #include <commoncpp/socket.h>
00062 #endif
00063
00064 NAMESPACE_COMMONCPP
00065
00092 class __EXPORT DCCPSocket : public Socket
00093 {
00094 union {
00095 struct sockaddr_in ipv4;
00096 #ifdef CCXX_IPV6
00097 struct sockaddr_in6 ipv6;
00098 #endif
00099 } peer;
00100
00101 Family family;
00102
00103 public:
00115 virtual bool onAccept(const IPV4Host &ia, tpport_t port);
00116 #ifdef CCXX_IPV6
00117 virtual bool onAccept(const IPV6Host &ia, tpport_t port);
00118 #endif
00119
00120 virtual IPV4Host getIPV4Sender(tpport_t *port = NULL) const;
00121
00122 #ifdef CCXX_IPV6
00123 virtual IPV6Host getIPV6Sender(tpport_t *port = NULL) const;
00124 #endif
00125
00137 DCCPSocket(const IPV4Address &bind, tpport_t port, unsigned backlog = 5);
00138 #ifdef CCXX_IPV6
00139 DCCPSocket(const IPV6Address &bind, tpport_t port, unsigned backlog = 5);
00140 #endif
00141
00151 DCCPSocket(const char *name, Family family = IPV4, unsigned backlog = 5);
00152
00156 DCCPSocket(Family family = IPV4);
00157
00161 DCCPSocket(DCCPSocket& server, timeout_t timeout = 0);
00162
00166 void reject(void);
00167
00171 void disconnect(void);
00172
00176 bool setCCID(uint8_t ccid);
00177
00181 int getTxCCID();
00182
00186 int getRxCCID();
00187
00191 size_t available();
00192
00200 void connect(const IPV4Host &host, tpport_t port, timeout_t timeout = 0);
00201 #ifdef CCXX_IPV6
00202 void connect(const IPV6Host &host, tpport_t port, timeout_t timeout = 0);
00203 #endif
00204
00208 void connect(const char *name);
00209
00215 inline bool isPendingConnection(timeout_t timeout = TIMEOUT_INF)
00216 {return Socket::isPending(Socket::pendingInput, timeout);}
00217
00221 virtual ~DCCPSocket();
00222 };
00223
00224 END_NAMESPACE
00225
00226 #endif