iocopy

An async io engine in 54 lines of C

Motivation

tcpforward

Common uses

Example

tcpforward -l 0.0.0.0:443 -c localhost:22

Motivation

tcpforward has a long-standing bug...

Motivation

tcpforward has a long-standing bug...

Motivation

54 lines of code should be enough for anyone, right?

Specification

What can we reuse?

What's still missing?

Specification

Basic operation: copy data between pairs of file descriptors.

What would a command line interface to this look like?

Specification

Basic operation: copy data between pairs of file descriptors.

What would a command line interface to this look like?

iocopy [options] rfd1 wfd1 rfd2 wfd2 ...

Specification

Q: What's an equivalent UNIX program for this invocation?

iocopy 0 1

Specification

Q: What's an equivalent UNIX program for this invocation?

iocopy 0 1

A: cat(1), dd(1), others

Specification

Here's another invocation:

iocopy v 0 7 6 1

Q: What is the significance of descriptors 6 and 7?

Implementation

The async io engine must do typical producer-consumer stuff:

Implementation

Implementation

Not obfuscated C per se... Some stats:

Demo

Thanks