WPILibC++  2018.4.1-20180729040223-1137-g011f0ff
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
TCPConnector.h
1 /*
2  TCPConnector.h
3 
4  TCPConnector class interface. TCPConnector provides methods to actively
5  establish TCP/IP connections with a server.
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_TCPCONNECTOR_H_
25 #define WPIUTIL_WPI_TCPCONNECTOR_H_
26 
27 #include <memory>
28 #include <utility>
29 
30 #include "wpi/ArrayRef.h"
31 #include "wpi/NetworkStream.h"
32 
33 namespace wpi {
34 
35 class Logger;
36 
37 class TCPConnector {
38  public:
39  static std::unique_ptr<NetworkStream> connect(const char* server, int port,
40  Logger& logger,
41  int timeout = 0);
42  static std::unique_ptr<NetworkStream> connect_parallel(
43  ArrayRef<std::pair<const char*, int>> servers, Logger& logger,
44  int timeout = 0);
45 };
46 
47 } // namespace wpi
48 
49 #endif // WPIUTIL_WPI_TCPCONNECTOR_H_
Definition: TCPConnector.h:37
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:41
namespace to hold default to_json function
Definition: SmallString.h:21
Definition: Logger.h:30