reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
TcpServer.hxx
Go to the documentation of this file.
1#ifndef TCP_SERVER_HXX
2#define TCP_SERVER_HXX
3
4#include <asio.hpp>
5#ifdef USE_SSL
6#include <asio/ssl.hpp>
7#endif
8#include <string>
9#include "TcpConnection.hxx"
10#include "ConnectionManager.hxx"
11#include "RequestHandler.hxx"
12
13namespace reTurn {
14
16{
17public:
18 // noncopyable
19 TcpServer(const TcpServer&) = delete;
20 TcpServer& operator=(const TcpServer&) = delete;
21
23 explicit TcpServer(asio::io_context& ioService, RequestHandler& rqeuestHandler, const asio::ip::address& address, unsigned short port);
24
25 void start();
26
27private:
29 void handleAccept(const asio::error_code& e);
30
32 asio::io_context& mIOService;
33
35 asio::ip::tcp::acceptor mAcceptor;
36
38 ConnectionManager mConnectionManager;
39
41 ConnectionPtr mNewConnection;
42
44 RequestHandler& mRequestHandler;
45};
46
47}
48
49#endif
50
51
52/* ====================================================================
53
54 Copyright (c) 2007-2008, Plantronics, Inc.
55 All rights reserved.
56
57 Redistribution and use in source and binary forms, with or without
58 modification, are permitted provided that the following conditions are
59 met:
60
61 1. Redistributions of source code must retain the above copyright
62 notice, this list of conditions and the following disclaimer.
63
64 2. Redistributions in binary form must reproduce the above copyright
65 notice, this list of conditions and the following disclaimer in the
66 documentation and/or other materials provided with the distribution.
67
68 3. Neither the name of Plantronics nor the names of its contributors
69 may be used to endorse or promote products derived from this
70 software without specific prior written permission.
71
72 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
73 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
74 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
75 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
76 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
77 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
78 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
79 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
80 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
81 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
82 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
83
84 ==================================================================== */
Manages open connections so that they may be cleanly stopped when the server needs to shut down,...
The common handler for all incoming requests.
TcpServer(const TcpServer &)=delete
TcpServer & operator=(const TcpServer &)=delete
std::shared_ptr< AsyncSocketBase > ConnectionPtr
void list()
Definition userAdmin.cxx:66