Using telnet to communicate with QNX Neutrino via TCP/IP in C++ - 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

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.
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.
Consider just using expect to solve your problem :)

You should start by learning the network API for the system you're trying to connect from. Telnet is just sending straight up text through a tcp/ip socket.

Related

How to find PC local IP from ESP32 to use MQTT nodejs server

I am working on a project and I need all my ESP32s to communicate with my PC to relay information. I am developing my MQTT server and I would need a way to find the IP of the PC which hosts the MQTT server to be able to send it the data from the ESP32.
Long time ago I tried to deal with NetBIOS broadcast but it's really unstable and complex to code in Arduino C++.
mDNS is what you are looking for.
The correct service type for MQTT is _mqtt._tcp.
There are plenty of libraries that support publishing mDNS services such as Avahi on Linux.
Windows doesn't support mDNS as a client but iirc you can install the Apple printer driver kit to add support.
If you can't get mDNS to work, and if you have full control of the LAN's router: some routers can act both as a DNS proxy and as a LAN DNS server, see here for example.
You can then connect by name or get the IP address without further configuration of the ESP32 (unless you change the server name, of course). It won't show you directly if the _mqtt._tcp service is available, though.

C++ Multicasting while connected through Mobile Hotspot device

I'm new to network programming in C++ and I'm writing a very simple app that is suppose to do a multicast.
From my research I see one of the first things I need to do is find out if my router supports multicast forwarding and multicast routing protocols.
My point of confusion is, I am connected to the internet via a mobile hotspot device, and I don't exactly know how to find out if it supports multicasting.
Does anyone know how I can go about finding out if I can indeed send multicasts with this type of wireless connection?
Thanks
I found that on a linux box (that supports ifconfig) you can use the ifconfig command to see if multicast is supported. eth0 for example will show Multicast along with some other information.
For windows in the command line:
netsh interface ip show joins
should tell you

Detect devices on local network for client-server connection in C++

I'm trying to implement an auto-connect feature for my Android application DroidPad, which is basically a TCP server running on an Android phone which the PC application connects to.
To make the process easier for the user, is there any way in (portable?) C++ to scan the IP addresses on the local subnet, possibly ones with a certain open port? I've tried using UDP broadcasting, but couldn't get it to work. I'm currently using the wxWidgets toolkit for GUI and libraries.
Any ideas?
I found a solution: wxServDisc. It uses mDNS (aka Zeroconf / Bonjour) to discover devices on a subnet, and is also based on wxWidgets.

Communicating over telnet

I can't use Boost ASIO (reasons not related to programming) and I looked around and libcurl looks good. I'm building the binaries at the moment and decided to get some feedback from the community.
Any comments regarding libcurl/alternatives?
UPDATE:
libcurl's not great for telnet. It's 2010! Shouldn't there be a simple way to do this? Winsock?
Telnet is a very simple protocol. Some wonky stuff to negotiate the terminal type but I'm sure your robot doesn't care where the cursor ends up. Just use a socket to open a TCP/IP connection on port 23 and send the command strings, terminated with a '\n'.
RFC854 is referring to it as a protocol, so perhaps it is one.
When I think of telnet I think of connecting to port 23 on a VT100 to get a terminal window to a remote UNIX host. You can also use telnet to other ports to get a TCP/IP connection which we used to use years ago on MUD/Talker servers, but this is simply a regular TCP/IP connection that is used in a connection-based client-server application. Actually "connectionless" is a misnomer as you do connect to the remote server, just in the connectionless model you do not retain the connection throughout the session, whereas in a connection-based model, the session begins when the client connects and ends when it disconnects.

dhcp client on linux, port or use?

On linux platform, I want to have dhcp client.
port any open source client to my app (which seems to be a bit time consuming)?
or communicate with the standalone client app via Signals?
or anyone knows any dhcp client library?
thanks for any advice.
You mean you want your app to tell the computer to DHCP? I would talk to dhcpcd using command line arguments and not do tons of extra work.