Unless the point is to learn about socket programming, I'd go with a library like
Jakarta Commons Net, which implements the Telnet protocol, amongst others.
Emulating Putty is much harder, because it implements SSH, where all kinds of security and encryption features need to be implemented.