/epoll-tcp-port-forward

a small demo shows how to use epoll.small program implements port forwarding with epoll.also support Windows using wepoll

Primary LanguageCMIT LicenseMIT

epoll-tcp-port-forward

This program implements TCP port forwarding using epoll.
It is designed for those who want to learn epoll through a practical project.
Note: This program is not recommended for production use.
For production, IPTABLES IS A BETTER CHOICE.

Compile And Run

# Requires cmake to build this project
cd epoll-tcp-port-forward
cmake -B ./build .
cmake --build build --config MinSizeRel --target all
./build/tcp_port_forward 31212 127.0.0.1 22 # Forward any data from port 31212 to local port 22

Alternatively, you can simply run:

gcc tcp_port_forward.c
./a.out 31212 127.0.0.1 22 # Forward any data from port 31212 to local port 22

Windows

There's no native epoll support on Windows.
Thanks to wepoll,an open source library that implements epoll API,you could still run this project on Windows.

cd epoll-tcp-port-forward\windows
git submodule update --init
cmake -B ./build .
cmake --build build --config MinSizeRel --target all
.\build\tcp_port_forward 31212 127.0.0.1 22 # Forward any data from port 31212 to local port 22