WPILibC++ 2024.3.2
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
13namespace 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 */
20 public:
21 PortForwarder(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 */
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:
52
53 struct Impl;
54 std::unique_ptr<Impl> m_impl;
55};
56
57} // namespace wpi
58
59#endif // WPINET_PORTFORWARDER_H_
Forward ports to another host.
Definition: PortForwarder.h:19
void Add(unsigned int port, std::string_view remoteHost, unsigned int remotePort)
Forward a local TCP port to a remote host and port.
PortForwarder & operator=(const PortForwarder &)=delete
static PortForwarder & GetInstance()
Get an instance of the PortForwarder class.
void Remove(unsigned int port)
Stop TCP forwarding on a port.
PortForwarder(const PortForwarder &)=delete
basic_string_view< char > string_view
Definition: core.h:501
Definition: ntcore_cpp.h:26