Generic socket server for testing

Originally published October 27, 2010.
Information provided in this post may be out of date.

Here’s a useful one-liner for running a generic socket server. I came up with this socat-based alternative to writing my own for testing client output. It listens on port 4096, accepts TCP/IP connections, and prints input received to stdout.

socat TCP-L:4096,fork -

Socat is quite powerful, be sure to read more about what it can do.

2011-July-08: My coworker has a great post showing how socat can pipe data from a serial port to a socket!