in reply to STDIN not working, STDIN hanging

You're reading until the socket is closed, but the client won't close the socket until it has received its reply.

When responding, list some similar code that works, without CGI.pm or other Module, because I believe the above examples should work as is without any Modules.

Of course it should work without modules because there's no difference between a script and a module.

When responding, list some similar code that works

I'm not about to copy CGI here.