Page 1 of 2
A simple Web server
Posted: Fri Feb 04, 2022 3:36 pm
by Martin_Head
About 6 years ago, I submitted an article to Quanta, On how to build a simple web server.
However, I don't remember ever seeing the article in print.
A while ago I came across this article. So I thought I would quickly dust it off, and add the graphics and file support I didn't include in the original article. And post it here for anyone who might be interested.
At least that was the plan....
I added the graphics and file support, and tested it on my PC with Firefox and QPC2. And every thing looked good.
So I then I thought I would try it with Internet Explorer, and a (pre-chrome) Edge. And that's when things fell apart. I've spent some time sorting out a lot of the problems that Firefox did not seem to mind about. And I also got it to work with my Ethernet driver for the Q68.
On my system, IE and Edge can still cause problems when using the 'localhost' with QPC2. It seems to trash the IP connection, giving Transmission errors in QPC2.
The webserver runs in BASIC on SMSQ/E systems that support the IP Device driver.
There is a get you started document, Just unzip the program and run the webserver2_bas program. You can also run it in a SBASIC daughter job.
I have supplied a small web site to go with it, and a copy of the original Quanta submission.
Re: A simple Web server
Posted: Fri Feb 04, 2022 4:02 pm
by pjw
Amazing!
I unzipped it to ram1_ and ran it from there, however, I got 404 messages. So I renamed all the files from *_ext to *.ext and then everything worked!
The program does eat up rather a lot of CPU cycles while its running - even when idle. Can anything be done about that?
Re: A simple Web server
Posted: Sat Feb 05, 2022 10:54 am
by Martin_Head
pjw wrote:Amazing!
I unzipped it to ram1_ and ran it from there, however, I got 404 messages. So I renamed all the files from *_ext to *.ext and then everything worked!
The program does eat up rather a lot of CPU cycles while its running - even when idle. Can anything be done about that?
All of the website files should have .ext , as you would expect on a PC. If you used QPC2 V5, it probably changed the extensions for you. It caught me out like that.
It sits in a loop waiting for connection requests. You could try running the program in a SBASIC daughter job and reducing the jobs priority. Or maybe stick a PAUSE in the wait loop, or are there any BASIC commands to suspend a job for a certain time?
The IP device driver should queue a certain number of connection requests, So if one arrived while paused it would not be lost.
Re: A simple Web server
Posted: Sun Feb 06, 2022 5:59 pm
by bixio60
Martin_Head wrote:pjw wrote:Amazing!
I unzipped it to ram1_ and ran it from there, however, I got 404 messages. So I renamed all the files from *_ext to *.ext and then everything worked!
The program does eat up rather a lot of CPU cycles while its running - even when idle. Can anything be done about that?
All of the website files should have .ext , as you would expect on a PC. If you used QPC2 V5, it probably changed the extensions for you. It caught me out like that.
It sits in a loop waiting for connection requests. You could try running the program in a SBASIC daughter job and reducing the jobs priority. Or maybe stick a PAUSE in the wait loop, or are there any BASIC commands to suspend a job for a certain time?
The IP device driver should queue a certain number of connection requests, So if one arrived while paused it would not be lost.
Great Martin, thank you!
No problem using my Macbook M1 with Chrome, I just started to convert my web site to the new QApache server.....So far my web site is hosted on a Synology NAS (soon will move to Q68) and I did it using MS FronPage.
Again thank you to you and all the other people that bring some life with active development......
Fabrizio
Re: A simple Web server
Posted: Mon Feb 07, 2022 11:29 am
by pjw
Martin_Head wrote:pjw wrote:Amazing!

<>
The program does eat up rather a lot of CPU cycles while its running - even when idle. Can anything be done about that?
<>
It sits in a loop waiting for connection requests. You could try running the program in a SBASIC daughter job and reducing the jobs priority. Or maybe stick a PAUSE in the wait loop, or are there any BASIC commands to suspend a job for a certain time?
The IP device driver should queue a certain number of connection requests, So if one arrived while paused it would not be lost.
Code: Select all
322 spjob -1, 1
330 REMark Main loop, Accept and process requests
340 PRINT#5,"Simple Web Serwer started ";DATE$
350 REPeat MainLoop
360 ch=IP_ACCEPT(#4)
370 IF ch>0 THEN
380 PRINT#5,DATE$!!"Connection made..."
390 DoRequest ch
400 CLOSE#ch
410 PRINT#5,DATE$!!"Connection ended..."
420
430 else
440 IF ch<>-1 THEN
450 REMark Something went wrong during accept
460 PRINT#0,"Failure in Accept - ";:REPORT ch
470 STOP
480 END IF
482 endif
484 susjb -1, 5
490 END REPeat MainLoop
500 :
The modifications made above appear to help a lot. Now I can use my system for other things even while the server is running. Of course, this was just a quick POC test.
Re: A simple Web server
Posted: Mon Feb 07, 2022 12:27 pm
by mk79
I currently don't have the time to look into this in detail, but I *think* normally you do a IOB_TEST with a timeout on the listening channel to see if there is anything to accept. Only if that returns "ok" then you do the accept call. This way the I/O system handles this like any other pending I/O without much CPU usage.
Re: A simple Web server
Posted: Mon Feb 07, 2022 2:14 pm
by mk79
P.S.: Was curious enough to spend a little time on it after all (and glad I did because it uncovered a few subtle but severe bugs in the IP driver of the unreleased next QPC!). Anyway, inserting "355 x = EOFW(#4)" should help the CPU issue
Re: A simple Web server
Posted: Mon Feb 07, 2022 6:27 pm
by pjw
mk79 wrote:P.S.: Was curious enough to spend a little time on it after all (and glad I did because it uncovered a few subtle but severe bugs in the IP driver of the unreleased next QPC!). Anyway, inserting "355 x = EOFW(#4)" should help the CPU issue
I think you nailed it!

Re: A simple Web server
Posted: Mon Feb 07, 2022 7:12 pm
by RalfR
Re: A simple Web server
Posted: Wed Feb 09, 2022 2:29 pm
by Tinyfpga
I am not sure what a web server is, but it sounds very interesting. I would like to thank Martin (and others?) for all his hard work.
I have downloaded the manual and am now trying to understand it. I have five questions as follows:-
1. Is it the case that the first example given in the manual is for a server running in QPC ( for example) and "read" by a browser on the same PC?
2. Can one have two PCs connected via an Ethernet cable and the server running in SMSQE (PC1) and the browser running in PC2?
3. What kind Ethernet cable does one use to connect two computers directly (ie not via a network switch)?
4. If one use a Q68 as a web server after installing the Ethernet Driver, does one then connect the Q68 to a PC with an Ethernet cable such that one can "read" the Q68 webpage in a browser?
5. Could one have a Q68 connected to many PCs via a network switch?