C++ Telnet

This is a discussion on C++ Telnet within the C++ Programming forums, part of the General Programming Boards category; I found out how to execute dos commands in C++ and get output in the console window. I connected to ...

C++ Telnet

I found out how to execute dos commands in C++ and get output in the console window. I connected to a telnet server but I couldn't call telnet commands by doing system(telnetcommand.c_str()); , is there a way to call telnet commands in C++?

Longer answer: No, because when you do the system() call that you're doing, you are just spawning another application process. Unless the application that is spawned has a method for inter-process communication (and you fork it - not just make a system call) then there's no way for your app to do anything with it.

In example, a piece of code that calls system("pause"); won't have execution returned to it until the pause process completes. Your code isn't even running while the process that system() called is done.

Edited to add: Also, using system() is inherantly dangerous. What happens when I replace telnet with an application that has viral code strewn throughout it? You just infected your system, but you won't know what caused it.

So there are no ways to do a telnet command in C++? are there any libraries for this? any at all?

You would have to write your own telnet-style application. To do this, you'd want to start learning about WinSock, and how to emulate different terminal types if you're going to emulate that functionality - like telnet can.

If you're talking about using the stock telnet application in your OS of choice and making system() calls, then no. It's just not possible, let alone not being adviseable or even remotely sane.

When I was learning WinSock I found the MSDN step-by-step walk through to be by far the most valuable resource I had. (In fact I ditched all of the tutorials I had even thought of reading because none of them were as good as that MSDN walk through) I'd provide a link but sadly I can't find it ;( (It's a real shame, it was a _really_ good step-by-step.)

When I was learning WinSock I found the MSDN step-by-step walk through to be by far the most valuable resource I had. (In fact I ditched all of the tutorials I had even thought of reading because none of them were as good as that MSDN walk through) I'd provide a link but sadly I can't find it ;( (It's a real shame, it was a _really_ good step-by-step.)

I know exactly what your talking about. When I first tried learning winsock MSDN was by far the most helpfull resource.

I think this was it: msdn.microsoft.com/en-us/library/ms738545(VS.85).aspx