~ubuntu-branches/ubuntu/maverick/libtorrent-rasterbar/maverick

« back to all changes in this revision

Viewing changes to include/libtorrent/udp_socket.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2010-08-10 12:59:37 UTC
  • mfrom: (1.3.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810125937-jbcmmf17y8yo9hgz
Tags: 0.15.0-0ubuntu1
* New upstream version.
* debian/patches/100_fix_html_docs.patch: refreshed.
* debian/control: bump up standards-version to 3.9.1 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#define TORRENT_UDP_SOCKET_HPP_INCLUDED
35
35
 
36
36
#include "libtorrent/socket.hpp"
 
37
#include "libtorrent/session_settings.hpp"
37
38
#include "libtorrent/buffer.hpp"
38
 
#include "libtorrent/session_settings.hpp"
39
39
 
40
40
#include <vector>
41
41
#include <boost/function.hpp>
54
54
                udp_socket(io_service& ios, callback_t const& c, connection_queue& cc);
55
55
                ~udp_socket();
56
56
 
57
 
                bool is_open() const { return m_ipv4_sock.is_open() || m_ipv6_sock.is_open(); }
 
57
                bool is_open() const
 
58
                {
 
59
                        return m_ipv4_sock.is_open()
 
60
#if TORRENT_USE_IPV6
 
61
                                || m_ipv6_sock.is_open()
 
62
#endif
 
63
                                ;
 
64
                }
58
65
                io_service& get_io_service() { return m_ipv4_sock.get_io_service(); }
59
66
 
60
67
                void send(udp::endpoint const& ep, char const* p, int len, error_code& ec);
66
73
                void set_proxy_settings(proxy_settings const& ps);
67
74
                proxy_settings const& get_proxy_settings() { return m_proxy_settings; }
68
75
 
 
76
                bool is_closed() const { return m_abort; }
 
77
 
69
78
        protected:
70
79
 
71
80
                struct queued_packet
99
108
                mutable mutex_t m_mutex;
100
109
 
101
110
                udp::socket m_ipv4_sock;
 
111
                udp::endpoint m_v4_ep;
 
112
                char m_v4_buf[1600];
 
113
 
 
114
#if TORRENT_USE_IPV6
102
115
                udp::socket m_ipv6_sock;
103
 
                udp::endpoint m_v4_ep;
104
116
                udp::endpoint m_v6_ep;
105
 
                char m_v4_buf[1600];
106
117
                char m_v6_buf[1600];
 
118
#endif
 
119
 
107
120
                int m_bind_port;
108
121
                char m_outstanding;
109
122
 
124
137
#ifdef TORRENT_DEBUG
125
138
                bool m_started;
126
139
                int m_magic;
 
140
                int m_outstanding_when_aborted;
127
141
#endif
128
142
        };
 
143
 
 
144
        struct rate_limited_udp_socket : public udp_socket
 
145
        {
 
146
                rate_limited_udp_socket(io_service& ios, callback_t const& c, connection_queue& cc);
 
147
                void set_rate_limit(int limit) { m_rate_limit = limit; }
 
148
                bool can_send() const { return int(m_queue.size()) >= m_queue_size_limit; }
 
149
                bool send(udp::endpoint const& ep, char const* p, int len, error_code& ec, int flags = 0);
 
150
                void close();
 
151
 
 
152
        private:
 
153
                void on_tick(error_code const& e);
 
154
 
 
155
                deadline_timer m_timer;
 
156
                int m_queue_size_limit;
 
157
                int m_rate_limit;
 
158
                int m_quota;
 
159
                ptime m_last_tick;
 
160
                std::list<queued_packet> m_queue;
 
161
        };
129
162
}
130
163
 
131
164
#endif