Demonstrate usage of listen(2) and facilitate INET-related experiments.
This project is a Dusk package that listen to a ipv4 socket that, by
default, is bound to 127.0.0.1:4242
. We accept any incoming connection and
echo back whatever is sent to it. Additionally, we print that received contents
to stdout.
This server can manage multiple connections and does so in a non-blocking way.
The package isn't designed to be very configurable, but rather to have a source code simple enough that it can easily be adapted to your needs.
This code is available from Dusk OS' files folder or as a Git repository (without SSL) at:
git://git.duskos.org/dusk-inet.git
To build this project, you need:
curl
, wget
, or BSD's ftp
.accept4(2)
The C code here is mostly POSIX, except for accept4(2)
, which comes from Linux
but is also implemented in NetBSD with the same semantics, so it's
semi-portable.
Running make
will download Dusk OS and compile the package using its
Usermode. The end result in a standalone dkinet
executable without
arguments.
You can use a tool like nc(1)
to establish a connection to that server.