reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
UdpEchoServer.hxx
Go to the documentation of this file.
1#ifndef UDPECHOSERVER_HXX
2#define UDPECHOSERVER_HXX
3
4#if defined(HAVE_CONFIG_H)
5#include "config.h"
6#endif
7
8#include <asio.hpp>
9#ifdef USE_SSL
10#include <asio/ssl.hpp>
11#endif
12#include <rutil/ThreadIf.hxx>
13
14using namespace std;
15using namespace resip;
16
17namespace reTurn {
18
20 {
21 public:
22 UdpEchoServer(const Data& localAddress, unsigned int port);
23 virtual ~UdpEchoServer() {}
24
25 unsigned int getPort() { return mPort; } // If port is passed in as 0 to constructor, this can be used to query the ephemeral port assigned
26
27 void thread() override;
28 void shutdown() override;
29
30 private:
31 void read();
32 void write();
33 void checkLog();
34
35 unsigned int mPort;
36 asio::io_context mIOContext;
37 asio::ip::udp::socket mSocket;
38 asio::ip::udp::endpoint mRemoteEndpoint;
39 char mReceiveBuffer[1500];
40 std::size_t mReceiveSize;
41
42 unsigned int mIntervalReadCount;
43 std::chrono::time_point<chrono::steady_clock> mTimeOfFirstRead;
44 };
45}
46
47#endif
48
49
50/* ====================================================================
51
52 Copyright (c) 2024 SIP Spectrum, Inc http://www.sipspectrum.com
53 All rights reserved.
54
55 Redistribution and use in source and binary forms, with or without
56 modification, are permitted provided that the following conditions are
57 met:
58
59 1. Redistributions of source code must retain the above copyright
60 notice, this list of conditions and the following disclaimer.
61
62 2. Redistributions in binary form must reproduce the above copyright
63 notice, this list of conditions and the following disclaimer in the
64 documentation and/or other materials provided with the distribution.
65
66 3. Neither the name of Plantronics nor the names of its contributors
67 may be used to endorse or promote products derived from this
68 software without specific prior written permission.
69
70 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
71 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
72 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
73 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
74 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
75 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
76 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
77 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
78 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
79 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
80 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
81
82 ==================================================================== */
void thread() override
void shutdown() override
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
A wrapper class to create and spawn a thread.
Definition ThreadIf.hxx:54
dcm! – add UnusedChecking(_enum) below;