I am trying to write a C or C++ program to control a telnet session. For the purpose of this question we could simplify the issue by assuming that I am relaying questions and answers to a user at the console. That's a simplification, but close enough.
I started out by opening a socket to the telnet port 23. I soon discovered that the handshake is complicated and there is no good documentation on what I have to do to satisfy the thing. Please don't tell me to read the telnet RFC because I did and it is the furthest thing imaginable from instructions on the negotiation.
Next I checked into the possibility that cURL could handle it, but there is nothing approaching actual instructions on how to write such a program and when I type cURL
telnet://xxx.xxx.xxx.xxx to see if at least I can do it interactively, it fails to relay things to and from the screen properly and freezes a lot.
Next, I checked into using popen, but I soon became convinced that I would need two pipes and simply don't know how to do it. I can control programs I write with a pair of pipes, but I am trying to control the telnet app that comes with Linux and this would seem to involve stdin and stdout. There is undoubtedly a way to do it by taking over stdin and stdout, but I sure don't know how.
Next up was IPWorks by nsoftware, and they even have a Telnet class, but it is utterly undocumented except for a class reference, which would be very hard to write an app from.
I would be grateful for any help I could get with this. I have been writing code and Googling for a day. Thanks in advance.
Brandon