WPILibC++
2025.0.0-alpha-1-24-g6478ba6
UDPClient.h
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
#ifndef WPINET_UDPCLIENT_H_
6
#define WPINET_UDPCLIENT_H_
7
8
#include <span>
9
#include <string>
10
#include <string_view>
11
12
#include <
wpi/SmallVector.h
>
13
#include <
wpi/mutex.h
>
14
15
namespace
wpi
{
16
17
class
Logger;
18
19
class
UDPClient
{
20
int
m_lsd;
21
int
m_port;
22
std::string m_address;
23
Logger
& m_logger;
24
25
public
:
26
explicit
UDPClient
(
Logger
& logger);
27
UDPClient
(
std::string_view
address,
Logger
& logger);
28
UDPClient
(
const
UDPClient
& other) =
delete
;
29
UDPClient
(
UDPClient
&& other);
30
~UDPClient
();
31
32
UDPClient
&
operator=
(
const
UDPClient
& other) =
delete
;
33
UDPClient
&
operator=
(
UDPClient
&& other);
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,
43
SmallVectorImpl<char>
* addr_received,
int
* port_received);
44
int
set_timeout
(
double
timeout);
45
};
46
47
}
// namespace wpi
48
49
#endif
// WPINET_UDPCLIENT_H_
SmallVector.h
This file defines the SmallVector class.
wpi::Logger
Definition:
Logger.h:27
wpi::SmallVectorImpl< char >
wpi::UDPClient
Definition:
UDPClient.h:19
wpi::UDPClient::operator=
UDPClient & operator=(const UDPClient &other)=delete
wpi::UDPClient::UDPClient
UDPClient(const UDPClient &other)=delete
wpi::UDPClient::shutdown
void shutdown()
wpi::UDPClient::set_timeout
int set_timeout(double timeout)
wpi::UDPClient::UDPClient
UDPClient(std::string_view address, Logger &logger)
wpi::UDPClient::UDPClient
UDPClient(Logger &logger)
wpi::UDPClient::start
int start(int port)
wpi::UDPClient::operator=
UDPClient & operator=(UDPClient &&other)
wpi::UDPClient::send
int send(std::span< const uint8_t > data, std::string_view server, int port)
wpi::UDPClient::send
int send(std::string_view data, std::string_view server, int port)
wpi::UDPClient::UDPClient
UDPClient(UDPClient &&other)
wpi::UDPClient::~UDPClient
~UDPClient()
wpi::UDPClient::start
int start()
wpi::UDPClient::receive
int receive(uint8_t *data_received, int receive_len, SmallVectorImpl< char > *addr_received, int *port_received)
wpi::UDPClient::receive
int receive(uint8_t *data_received, int receive_len)
mutex.h
wpi
Definition:
ntcore_cpp.h:26
string_view
basic_string_view< char > string_view
Definition:
base.h:601
wpinet
UDPClient.h
Generated on Sun Jul 7 2024 13:45:43 for WPILibC++ by
1.9.4