WPILibC++  unspecified
UDPClient.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #ifndef WPIUTIL_UDPSOCKETS_UDPCLIENT_H_
9 #define WPIUTIL_UDPSOCKETS_UDPCLIENT_H_
10 
11 #include <string>
12 
13 #include "llvm/ArrayRef.h"
14 #include "llvm/StringRef.h"
15 #include "support/mutex.h"
16 
17 namespace wpi {
18 
19 class Logger;
20 
21 class UDPClient {
22  int m_lsd;
23  std::string m_address;
24  Logger& m_logger;
25 
26  public:
27  explicit UDPClient(Logger& logger);
28  UDPClient(llvm::StringRef address, Logger& logger);
29  UDPClient(const UDPClient& other) = delete;
30  UDPClient(UDPClient&& other);
31  ~UDPClient();
32 
33  UDPClient& operator=(const UDPClient& other) = delete;
34  UDPClient& operator=(UDPClient&& other);
35 
36  int start();
37  void shutdown();
38  // The passed in address MUST be a resolved IP address.
39  int send(llvm::ArrayRef<uint8_t> data, llvm::StringRef server, int port);
40  int send(llvm::StringRef data, llvm::StringRef server, int port);
41 };
42 
43 } // namespace wpi
44 
45 #endif // WPIUTIL_UDPSOCKETS_UDPCLIENT_H_
Definition: UDPClient.h:21
Definition: SocketError.cpp:17
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:32
Definition: Logger.h:30
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:42