WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
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 "wpi/net/TCPStream.h"
34
35namespace wpi::util {
36class Logger;
37}
38
39namespace wpi::net {
41 int m_lsd;
42 int m_port;
43 std::string m_address;
44 bool m_listening;
45 std::atomic_bool m_shutdown;
46 wpi::util::Logger& m_logger;
47
48 public:
49 TCPAcceptor(int port, std::string_view address, wpi::util::Logger& logger);
50 ~TCPAcceptor() override;
51
52 int start() override;
53 void shutdown() final;
54 std::unique_ptr<NetworkStream> accept() override;
55};
56
57} // namespace wpi::net
58
59#endif // WPINET_TCPACCEPTOR_H_
Definition NetworkStream.hpp:12
int start() override
std::unique_ptr< NetworkStream > accept() override
TCPAcceptor(int port, std::string_view address, wpi::util::Logger &logger)
void shutdown() final
Definition Logger.hpp:26
Definition StringMap.hpp:773
Definition raw_socket_ostream.hpp:9
Definition raw_os_ostream.hpp:19