0

Is there a way for a computer to test a telnet connection to a local server using C++? I've used _popen() to pipe a telnet connection line into cmd and it connected to the server, but I haven't been able to find a way for my code to receive feedback on whether or not the connection was successful or not. And because a telnet connection opens a new window, I haven't figured out how to pipe commands into the telnet window or even just exit out of it automatically. Is there a way to have the code receive any indication that the connection was successful?

I'm on Windows 10 and am using Visual Studio Community 2019 with C++ 14

darren wu
  • 3
  • 2
  • 5
    Why not simply create a TCP socket and `connect()` it to the Telnet server, and then `send()` and `recv()` data as needed? Why are you going through the command line at all? See [Getting Started with Winsock](https://learn.microsoft.com/en-us/windows/win32/winsock/getting-started-with-winsock) and [Winsock Client Application](https://learn.microsoft.com/en-us/windows/win32/winsock/winsock-client-application). – Remy Lebeau Jun 07 '21 at 19:31
  • 1
    Why you test that ugly telnet client that is likely even not enabled on Windows 10 by default? Download some MudLet or TinTin++ source code to see how to make flexible and configurabletelnet client on windows. – Öö Tiib Jun 07 '21 at 21:13
  • Have a look for example code for popen2 which isn't standard but does what you want. There are lots of examples including https://stackoverflow.com/questions/33520838/how-does-popen2-work-in-c https://daniel.haxx.se/stuff/popen2.c https://emergent.unpythonic.net/01108826729 And this one if you are on windows: https://octave.org/doxygen/stable/d3/d09/octave-popen2_8c_source.html – Jerry Jeremiah Jun 08 '21 at 02:18

0 Answers0