rogue
Loading...
Searching...
No Matches
Server.h
Go to the documentation of this file.
1
17#ifndef __ROGUE_PROTOCOLS_UDP_SERVER_H__
18#define __ROGUE_PROTOCOLS_UDP_SERVER_H__
19#include "rogue/Directives.h"
20
21#include <netdb.h>
22#include <netinet/in.h>
23#include <netinet/ip.h>
24#include <stdint.h>
25#include <sys/socket.h>
26
27#include <memory>
28#include <thread>
29
30#include "rogue/Logging.h"
34
35namespace rogue {
36namespace protocols {
37namespace udp {
38
54 // Bound local UDP port.
55 uint16_t port_;
56
57 // Local bind socket address.
58 struct sockaddr_in locAddr_;
59
60 // Background receive thread entry point.
61 void runThread(std::weak_ptr<int>);
62
63 public:
78 static std::shared_ptr<rogue::protocols::udp::Server> create(uint16_t port, bool jumbo);
79
81 static void setup_python();
82
97 Server(uint16_t port, bool jumbo);
98
100 ~Server();
101
108 void stop();
109
115 uint32_t getPort();
116
126 void acceptFrame(std::shared_ptr<rogue::interfaces::stream::Frame> frame);
127};
128
129// Convenience
130typedef std::shared_ptr<rogue::protocols::udp::Server> ServerPtr;
131
132} // namespace udp
133} // namespace protocols
134}; // namespace rogue
135
136#endif
Stream master endpoint.
Definition Master.h:65
static std::shared_ptr< rogue::interfaces::stream::Master > create()
Creates a stream master.
Definition Master.cpp:40
Stream slave endpoint and default frame pool.
Definition Slave.h:72
Shared UDP transport base for stream client/server endpoints.
Definition Core.h:61
UDP stream endpoint that listens on a local UDP port.
Definition Server.h:53
~Server()
Destroys the UDP server endpoint.
Definition Server.cpp:103
void acceptFrame(std::shared_ptr< rogue::interfaces::stream::Frame > frame)
Accepts an outbound stream frame and transmits it as UDP datagrams.
Definition Server.cpp:122
void stop()
Stops the UDP server endpoint.
Definition Server.cpp:107
static void setup_python()
Registers Python bindings for this class.
Definition Server.cpp:239
uint32_t getPort()
Returns bound local UDP port number.
Definition Server.cpp:117
std::shared_ptr< rogue::protocols::udp::Server > ServerPtr
Definition Server.h:130