WPILibC++  2019.1.1-beta-2-22-gc405188
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
TCPAcceptor.h
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 WPIUTIL_WPI_TCPACCEPTOR_H_
25 #define WPIUTIL_WPI_TCPACCEPTOR_H_
26 
27 #include <atomic>
28 #include <memory>
29 #include <string>
30 
31 #include "wpi/NetworkAcceptor.h"
32 #include "wpi/TCPStream.h"
33 
34 namespace wpi {
35 
36 class Logger;
37 
38 class TCPAcceptor : public NetworkAcceptor {
39  int m_lsd;
40  int m_port;
41  std::string m_address;
42  bool m_listening;
43  std::atomic_bool m_shutdown;
44  Logger& m_logger;
45 
46  public:
47  TCPAcceptor(int port, const char* address, Logger& logger);
48  ~TCPAcceptor();
49 
50  int start() override;
51  void shutdown() override;
52  std::unique_ptr<NetworkStream> accept() override;
53 };
54 
55 } // namespace wpi
56 
57 #endif // WPIUTIL_WPI_TCPACCEPTOR_H_
Definition: TCPAcceptor.h:38
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21
Definition: NetworkAcceptor.h:17
Definition: Logger.h:30