Search code examples
c++tcpclienttelnetqnx-neutrino

Using telnet to communicate with QNX Neutrino via TCP/IP in C++


I'm able to access a telnet server via PuTTY which opens a terminal and allows me to send commands to retrieve data/logs and start/stop processes. I'd like to begin some research into how to access this server via C++ in order to automate the connection and the commands for testing. Basically I need a telnet client that can connect and authenticate itself, and write and read to/from the server as if I'm typing in a terminal. Where should I start my research? I've tried a couple examples including:

http://lists.boost.org/boost-users/att-40895/telnet.cpp

When I compile and run

./telnet 192.168.1.26 23

Nothing happens, but when I connect to the server with PuTTY I get:

QNX Neutrino (localhost) (ttyp0)

login: root  
password:  
#  

Any help would be greatly appreciated.
Notes:
- I am using a Mac running OS X Version 10.7.3 with i686-apple-darwin11-llvm-gcc-4.2
- I am allowed to be doing this.
- I use PuTTY on my Windows 7 machine, the connection is ethernet to USB ethernet adapter, and the settings for the Local Area Connection Properties > TCP/IPv4 Properties: are a specific IP address, Subnet Mask, and Default gateway, which might be useful information.

Thanks


Solution

    1. Learn how to program TCP/IP sockets. You can use the boost libraries, or straight C style BSD sockets. Some info here, here and here. If paper is your thing, you could get Volume 1 of Unix Network Programming. That book has such a good reputation that you get votes just for mentioning it on StackOverflow.

    2. What you want to do closely matches the functionality of telnet and expect. You can have a look at there sources here and here for ideas.

    3. Consider just using expect to solve your problem :)