Once upon a time I decided the Unix telnet daemon was scary and I would rewrite it. I didn't really realize just how scary it was.
The result of that project, connect.tar.gz, contains a program which will allow you to connect to a TCP/IP port and read and write it.
This program is like the better-known "netcat", but dumber.