Trying to emulate a very basic HTTP client

Hi folks

I work for a manufacturer of semiconductor equipment that I see from browsing the archives some of you are familiar with. I’m no expert on QNX but have got to know 4.25 reasonably well by necessity. Everyone who really understands it seems to have moved on some time ago.

I’m trying to achieve something that I hoped would be quite easy, but is turning out not to be. The idea is, from a QNX machine, to

$ telnet <ip> 80

to a robot controller with an embedded webserver and issue a GET to retrieve a couple of log files. If I try this from Windows telnet, it works just fine. Send the GET, hit enter twice and it spits the whole logfile out. It sends various headers but doesn’t seem to demand any of them.

From QNX 4.25 telnet, however, it just doesn’t work.

Firstly, it seems to mess with CR/LFs (by turning CR from 0x0D into 0x00 0x0D) although I guess that’s to be expected and I don’t think it’s actually the problem.

The real problem is that this web server doesn’t seem to want to start responding until a TCP FIN is sent. After opening the socket it will close it after 10 seconds if there is no input, but once you send a command, it’ll sit there waiting for a FIN for any amount of time and I can’t find any way of persuading QNX telnet to send a FIN, other than by exiting or killing the process. So once you close the telnet session you’re piping the input into, the server starts responding and actually sends a HTTP 200 OK response and some headers before QNX hits it with TCP RST until it stops.

I’ve copied the exact request that works from a Windows machine, saved it from wireshark, verified it in a hex editor, piped it into QNX telnet with the -8 option (for 8 bit mode, just in case that does anything) and it does not work. There is nothing I can find that makes the webserver start talking and keeps the socket open.

If someone is familiar with the issue and has a solution, that would be great. Alternatively, from browsing the archives, I see a few people claiming to have successfully ported netcat to QNX4.25. I don’t have a toolchain for QNX4.25 and wouldn’t fancy my chances of achieving this goal even if I did. If anyone has a binary of this somewhere they can share, I would be very grateful.

The only other alternative I can think of is that QNX4.25, or at least our build of it, does come with perl. I know nothing about perl and don’t want to, but it does seem possible chatgpt might guide me towards a working app that can send arbitrary commands over a TCP socket and save the output.

I’ll see what you guys have to say before pursuing that.

Many thanks
Gavin

EDIT: I should clarify I tried 1) using telnet interactively 2) piping input from a file into telnet and 2a) doing that, using a sleep 1 command. I even tried piping the input into a FIFO then into telnet - none of it works. Whatever I do, the server only starts responding then the process is killed. QNX telnet to Windows webserver does not have this problem. Neither does QNX telnet to Python webserver running on Linux.

I’ve worked with TCP/IP quite a lot, but I’m unfamiliar with what you are talking about. I looked up TCP FIN and it seems to be a message taht the client sends to close the connection. I don’t understand why you would want to close the connection before getting the response.

I have two thoughts on this. The first is that the QNX console options might be causing a problem. The stty command will tell you how things are set. Telnet may be changing these so you can start telnet and from a 2nd console check.

The second idea is that here is an open source command line program I’ve used with QNX 6 called curl:

https://curl.se/

If this could be ported to QNX 4.25, it might solve your problem. It has two modes, a utility and an API so you can take advantage of its built in protocols. I’ve used both modes. The latter of course requires a development system and some C coding.

BTW, as of recent, openqnx.com does not inform me anymore when there are replies, so you may ping me or contact me at maschoen@pobox.com if you wish.

Why can’t you use a QNX tool with a proper HTTP client, like the Mako Server?

QNX download page: https://makoserver.net/download/qnx/

HTTP client examples:
https://realtimelogic.com/ba/doc/en/lua/auxlua.html#httplib
https://tutorial.realtimelogic.com/HTTP-Client.lsp

I’m not sure, but I don’t think the robot client he is running is QNX. If it was, there would be better ways to download the logs other than using an http client and server.

Also, the Mako page you linked to says that it supports QNX 5 to 8. This is somewhat amusing as there is no such thing as QNX 5.

Wilfred, I’ll start with yours. Thanks for the reply. The main reason I didn’t use a QNX tool with a proper HTTP client is that although I suspected such a thing must exist, I couldn’t find one. I wasn’t expecting curl or wget but I was expecting to find something similar to Lynx out there somewhere given when QNX4 was released. In the end, I couldn’t find anything, which is what led me to telnet. I strongly suspect if I was asking this same question twenty years ago, it’s far more likely I’d find what I’m after very easily.

Regarding your links: if I’m to get into writing code in C and compiling it, then there are any number of solutions to this problem. If a binary exists, I would download it. I know from experience that to get from “here is some C code that might work” to a solved problem could be weeks of work.

What I’m trying to create here is a proof of concept, using tools available to me. The actual implementation would be written in C, by a development team, as part of an existing application that uses TCP sockets in several places. If it can’t be done relatively easily, I might as well just tell the dev team what I’d like the final version to do and let them implement it themselves.

Maschoen - thank you for the reply. I am familiar with the linux version of curl and it would be perfect, if it were available for QNX4 but if it’s not, I’m not the right person to port it.

Here’s a discussion that makes me think compiling anything at all will be an uphill struggle - for me personally I mean.

I mentioned in my post that perl was included in /usr/local/bin. I read some other post from the archives of this site which I can’t find now, but the gist of it was that that just because perl in general supports TCP/IP doesn’t necessarily mean that this particular implementation does.

That is very helpful information about stty. I didn’t do a great job of explaining the problem but it does seem likely that what telnet is doing to the CRs may be the entirety of the problem, and this does seem like it might be able to fix that. You are correct about the FIN flag not being the answer here. I don’t want to close the connection - the fact that closing the connection makes the server start responding is probably a bug. I just thought it was interesting.

The web server is called Wind River Embedded Web Server and you are correct that it doesn’t run on QNX. It’s on a Yaskawa robot controller. I don’t know if it even has an OS per se.

I will do some reading up on and experimentation with stty and let you know how I get on.

I might have lynx around for QNX 4. Message me at maschoen@gmail.com if you want me to take a look.

In case you don’t know this, WInd River is an RTOS competitor to QNX so the Wind River Embedded Web Server is probably running on the Wind River OS.

Maschoen

I was planning to drop you a line anyway. Just to let you know that I tried a minimal “open socket, send GET” implementation using perl (v5.005 is what’s included in /usr/local/bin), and it works great on my python-based test web server. So did telnet, of course, but I’ve just checked the packet capture using the perl script and the CR LFs are intact (0x0d 0x0a with no 0x00 in between) so I’ll be surprised if it doesn’t play nice with the Wind River web server also. I have not encountered Wind River outside of this context so thanks for that info.

Using perl is technically a lot less of a hack than the telnet method and assuming it works on the robot controller, I’m very happy to proceed with it. I’ll report back either way.

Thanks again for your help with this, I really appreciate it.

Kind regards
Gavin

In case anyone is interested, I finished a very rough port of curl to QNX 4. It might only be good for downloading unencrypted web files. I haven’t tried ftp, but that might also work.