]> git.sesse.net Git - cubemap/blob - udpstream.h
Merge branch 'master' of /srv/git.sesse.net/www/cubemap
[cubemap] / udpstream.h
1 #ifndef _UDPSTREAM_H
2 #define _UDPSTREAM_H 1
3
4 // A single UDP destination. This is done a lot less efficient than HTTP streaming
5 // since we expect to have so few of them, which also means things are a lot simpler.
6 // In particular, we run in the input's thread, so there is no backlog, which means
7 // that there is no state (UDP itself is, of course, stateless).
8
9 #include <arpa/inet.h>
10 #include <stddef.h>
11 #include <stdint.h>
12 #include <sys/types.h>
13
14 class MarkPool;
15
16 class UDPStream {
17 public:
18         // <mark_pool> can be NULL. Does not take ownership of the mark pool.
19         UDPStream(const sockaddr_in6 &dst, MarkPool *mark_pool);
20         ~UDPStream();
21
22         void send(const char *data, size_t bytes);
23
24 private:
25         UDPStream(const UDPStream& other);
26
27         sockaddr_in6 dst;
28         int sock;
29         MarkPool *mark_pool;
30         int fwmark;
31 };
32
33 #endif  // !defined(_UDPSTREAM_H)