A simple Web server
-
- Aurora
- Posts: 992
- Joined: Tue Dec 17, 2013 1:17 pm
A simple Web server
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.
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.
- Attachments
-
- webserver.zip
- (173.52 KiB) Downloaded 85 times
-
- QuantaWebServer.zip
- (281.53 KiB) Downloaded 103 times
Re: A simple Web server
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?

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?
Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
-
- Aurora
- Posts: 992
- Joined: Tue Dec 17, 2013 1:17 pm
Re: A simple Web server
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.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?
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
Great Martin, thank you!Martin_Head wrote: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.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?
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.
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
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 :
Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
- mk79
- QL Wafer Drive
- Posts: 1349
- Joined: Sun Feb 02, 2014 10:54 am
- Location: Esslingen/Germany
- Contact:
Re: A simple Web server
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.
- mk79
- QL Wafer Drive
- Posts: 1349
- Joined: Sun Feb 02, 2014 10:54 am
- Location: Esslingen/Germany
- Contact:
Re: A simple Web server
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
I think you nailed it!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

Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
Re: A simple Web server
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?
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?