WPILibC++ 2024.3.2
TCPAcceptor.h
Go to the documentation of this file.
1/*
2 TCPAcceptor.h
3
4 TCPAcceptor class interface. TCPAcceptor provides methods to passively
5 establish TCP/IP connections with clients.
6
7 ------------------------------------------
8
9 Copyright (c) 2013 [Vic Hargrave - http://vichargrave.com]
10
11 Licensed under the Apache License, Version 2.0 (the "License");
12 you may not use this file except in compliance with the License.
13 You may obtain a copy of the License at
14
15 http://www.apache.org/licenses/LICENSE-2.0
16
17 Unless required by applicable law or agreed to in writing, software
18 distributed under the License is distributed on an "AS IS" BASIS,
19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 See the License for the specific language governing permissions and
21 limitations under the License.
22*/
23
24#ifndef WPINET_TCPACCEPTOR_H_
25#define WPINET_TCPACCEPTOR_H_
26
27#include <atomic>
28#include <memory>
29#include <string>
30#include <string_view>
31
33#include "wpinet/TCPStream.h"
34
35namespace wpi {
36
37class Logger;
38
40 int m_lsd;
41 int m_port;
42 std::string m_address;
43 bool m_listening;
44 std::atomic_bool m_shutdown;
45 Logger& m_logger;
46
47 public:
48 TCPAcceptor(int port, std::string_view address, Logger& logger);
49 ~TCPAcceptor() override;
50
51 int start() override;
52 void shutdown() final;
53 std::unique_ptr<NetworkStream> accept() override;
54};
55
56} // namespace wpi
57
58#endif // WPINET_TCPACCEPTOR_H_
Definition: Logger.h:27
Definition: NetworkAcceptor.h:14
Definition: NetworkStream.h:13
Definition: TCPAcceptor.h:39
void shutdown() final
TCPAcceptor(int port, std::string_view address, Logger &logger)
std::unique_ptr< NetworkStream > accept() override
int start() override
~TCPAcceptor() override
basic_string_view< char > string_view
Definition: core.h:501
Definition: array.h:89
Definition: ntcore_cpp.h:26