WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
UDPClient.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <span>
8#include <string>
9#include <string_view>
10
11#include "wpi/util/SmallVector.hpp"
12#include "wpi/util/mutex.hpp"
13
14namespace wpi::util {
15class Logger;
16}
17
18namespace wpi::net {
19class UDPClient {
20 int m_lsd;
21 int m_port;
22 std::string m_address;
23 wpi::util::Logger& m_logger;
24
25 public:
26 explicit UDPClient(wpi::util::Logger& logger);
27 UDPClient(std::string_view address, wpi::util::Logger& logger);
28 UDPClient(const UDPClient& other) = delete;
31
32 UDPClient& operator=(const UDPClient& other) = delete;
34
35 int start();
36 int start(int port);
37 void shutdown();
38 // The passed in address MUST be a resolved IP address.
39 int send(std::span<const uint8_t> data, std::string_view server, int port);
40 int send(std::string_view data, std::string_view server, int port);
41 int receive(uint8_t* data_received, int receive_len);
42 int receive(uint8_t* data_received, int receive_len,
44 int* port_received);
45 int set_timeout(double timeout);
46};
47
48} // namespace wpi::net
UDPClient & operator=(UDPClient &&other)
UDPClient(UDPClient &&other)
int receive(uint8_t *data_received, int receive_len, wpi::util::SmallVectorImpl< char > *addr_received, int *port_received)
UDPClient(wpi::util::Logger &logger)
int send(std::span< const uint8_t > data, std::string_view server, int port)
UDPClient(std::string_view address, wpi::util::Logger &logger)
UDPClient & operator=(const UDPClient &other)=delete
UDPClient(const UDPClient &other)=delete
int set_timeout(double timeout)
int send(std::string_view data, std::string_view server, int port)
int start(int port)
int receive(uint8_t *data_received, int receive_len)
Definition Logger.hpp:26
Definition BooleanTopic.hpp:24
Definition raw_socket_ostream.hpp:9
Definition raw_os_ostream.hpp:19