Сделаем это с помощью socat:
socat tcp-l:20445,reuseaddr,fork system:'echo hello; sleep 5; echo goodbye',nofork
Проверка:
telnet your-hostname.com 20445
Trying 1.11.111.111...
Connected to your-hostname.com.
Escape character is '^]'.
hello
goodbye
Connection closed by foreign host.