WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
PortForwarder.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 <memory>
8#include <string_view>
9
10namespace wpi::net {
11
12/**
13 * Forward ports to another host. This is primarily useful for accessing
14 * Ethernet-connected devices from a computer tethered to the RoboRIO USB port.
15 */
17 public:
18 PortForwarder(const PortForwarder&) = delete;
20
21 /**
22 * Get an instance of the PortForwarder class.
23 *
24 * This is a singleton to guarantee that there is only a single instance
25 * regardless of how many times GetInstance is called.
26 */
28
29 /**
30 * Forward a local TCP port to a remote host and port.
31 * Note that local ports less than 1024 won't work as a normal user.
32 *
33 * @param port local port number
34 * @param remoteHost remote IP address / DNS name
35 * @param remotePort remote port number
36 */
37 void Add(unsigned int port, std::string_view remoteHost,
38 unsigned int remotePort);
39
40 /**
41 * Stop TCP forwarding on a port.
42 *
43 * @param port local port number
44 */
45 void Remove(unsigned int port);
46
47 private:
49
50 struct Impl;
51 std::unique_ptr<Impl> m_impl;
52};
53
54} // namespace wpi::net
PortForwarder & operator=(const PortForwarder &)=delete
void Remove(unsigned int port)
Stop TCP forwarding on a port.
void Add(unsigned int port, std::string_view remoteHost, unsigned int remotePort)
Forward a local TCP port to a remote host and port.
PortForwarder(const PortForwarder &)=delete
static PortForwarder & GetInstance()
Get an instance of the PortForwarder class.
Definition raw_socket_ostream.hpp:9