WPILibC++
2025.0.0-alpha-1-24-g6478ba6
PortForwarder.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_PORTFORWARDER_H_
6
#define WPINET_PORTFORWARDER_H_
7
8
#pragma once
9
10
#include <memory>
11
#include <string_view>
12
13
namespace
wpi
{
14
15
/**
16
* Forward ports to another host. This is primarily useful for accessing
17
* Ethernet-connected devices from a computer tethered to the RoboRIO USB port.
18
*/
19
class
PortForwarder
{
20
public
:
21
PortForwarder
(
const
PortForwarder
&) =
delete
;
22
PortForwarder
&
operator=
(
const
PortForwarder
&) =
delete
;
23
24
/**
25
* Get an instance of the PortForwarder class.
26
*
27
* This is a singleton to guarantee that there is only a single instance
28
* regardless of how many times GetInstance is called.
29
*/
30
static
PortForwarder
&
GetInstance
();
31
32
/**
33
* Forward a local TCP port to a remote host and port.
34
* Note that local ports less than 1024 won't work as a normal user.
35
*
36
* @param port local port number
37
* @param remoteHost remote IP address / DNS name
38
* @param remotePort remote port number
39
*/
40
void
Add
(
unsigned
int
port,
std::string_view
remoteHost,
41
unsigned
int
remotePort);
42
43
/**
44
* Stop TCP forwarding on a port.
45
*
46
* @param port local port number
47
*/
48
void
Remove
(
unsigned
int
port);
49
50
private
:
51
PortForwarder
();
52
53
struct
Impl;
54
std::unique_ptr<Impl> m_impl;
55
};
56
57
}
// namespace wpi
58
59
#endif
// WPINET_PORTFORWARDER_H_
wpi::PortForwarder
Forward ports to another host.
Definition:
PortForwarder.h:19
wpi::PortForwarder::Add
void Add(unsigned int port, std::string_view remoteHost, unsigned int remotePort)
Forward a local TCP port to a remote host and port.
wpi::PortForwarder::operator=
PortForwarder & operator=(const PortForwarder &)=delete
wpi::PortForwarder::GetInstance
static PortForwarder & GetInstance()
Get an instance of the PortForwarder class.
wpi::PortForwarder::Remove
void Remove(unsigned int port)
Stop TCP forwarding on a port.
wpi::PortForwarder::PortForwarder
PortForwarder(const PortForwarder &)=delete
wpi
Definition:
ntcore_cpp.h:26
string_view
basic_string_view< char > string_view
Definition:
base.h:601
wpinet
PortForwarder.h
Generated on Sun Jul 7 2024 13:45:43 for WPILibC++ by
1.9.4