Slashdot Log In
A TCP/IP Stack and Web Server In BASIC
Posted by
CowboyNeal
on Sat Aug 16, 2003 08:31 AM
from the rebirth-of-the-line-editor dept.
from the rebirth-of-the-line-editor dept.
A writes "Back in the day, a BASIC interpreter was standard on every home computer system and everyone had to know at least a little BASIC to be able to use their computer. But who would have thought that you could write some serious networking code in BASIC over 20 years later? Just a few days ago, Lee Davison released the BASIC source code for his 6502-based Ethernet web server. The web server runs under his EhBASIC interpreter on the 1 MHz 6502 CPU and is able to blast out web pages at an amazing speed of 20-35 seconds per page!" Sure, it's not really practical, but I give it cool points.
This discussion has been archived.
No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Full
Abbreviated
Hidden
Loading... please wait.
Down in three seconds flat (Score:5, Funny)
Re:Down in three seconds flat (Score:5, Informative)
is one of those "non-routable private IP address spaces".
RTFRFC
Parent
R *this* FRFC. (Score:5, Informative)
Parent
Re:Down in three seconds flat (Score:5, Funny)
Here [169.254.226.132] you go
Parent
Re:Down in three seconds flat (Score:5, Funny)
Parent
Re:Down in three seconds flat (Score:5, Funny)
Yeah, and anyone stupid enough to believe it'll work outside of a local network should also try 127.0.0.1 for a cool Pr0n site!
Parent
Re:Down in three seconds flat (Score:5, Funny)
Parent
Re:Down in three seconds flat (Score:3, Funny)
Well, if you'd open 127.0.0.1:31337 and discover a kiddie porn site, you can be pretty sure there's a trojan somewhere on your computer
Unless, of course...
Re:Down in three seconds flat (Score:2)
Am I the only one (Score:3, Funny)
How long til it gets slashdotted? (Score:2, Funny)
(I know the article isn't on the EhBASIC webserver - I was talking about any page served up by the webserver alone.)
Re:How long til it gets slashdotted? (Score:5, Funny)
This "BASIC" Webserver & TCP/IP Stack will go down in the annals of History as being the first ever webserver to become
Parent
To quote Zahpod Beeblebrox... (Score:5, Funny)
I actually have some Apple
Re:To quote Zahpod Beeblebrox... (Score:2, Interesting)
You can use a BASIC dialect that has a built-in assembler and so still get suitably old-school source code.
Imagine.. (Score:5, Funny)
20-35 Seconds Per Page?!? (Score:5, Funny)
Cowabunga! (Score:2, Funny)
Re:Cowabunga! Nope! (Score:3, Informative)
Somebody needs to attend the Vintage Computer Festival [vintage.org]! The TRS-80 Model I, II, III, 4, et al used the Z-80, not the 6502. Unless you mean the Color Computer, which (iirc) used the 6809. There was another one (Model 6000?) that used the 68000, iirc. But no 6502's.
I get a slightly faster transfer speed (Score:5, Funny)
Looks more like assembler to me... (Score:5, Interesting)
Re:Looks more like assembler to me... (Score:2, Interesting)
Re:Looks more like assembler to me... (Score:2)
Re:Looks more like assembler to me... (Score:5, Interesting)
- Variable names limited to two characters
- Only data types are integers and strings
- No structured data types, only (fixed size) arrays
- No names in control flow, just GOTO 100 and GOSUB 9000. No parameters for subroutines.
- Plus, it was typically interpreted, for extra slowness at run time.
It's worse than assembly. At least in assembly, you can have longer identifiers, and use them in data and control flow statements.Parent
Re:Looks more like assembler to me... (Score:5, Informative)
Also, there were user-defined one-line functions with parameters, which could even be recursive, as in: DEF FNX(P1,P2)=Y where X is the function name, P1 and P2 are parameters and Y is an expression. No argument there!
Parent
Re:Looks more like assembler to me... (Score:5, Informative)
Parent
clarification (Score:3, Interesting)
It's worth mentioning that, for the C64/128 at least, you could actually have variable names longer than two characters but only the first two characters would be recognized. All the rest were ignored. By way of example, here's a made up code sample. Since my C128 is currently in the closet, I can't guarentee this example's accuracy. Some other pedant may wish to.
Example
10 LET FROGS = 16
20 LET FRAGGLE = 12
30 LET FRANCE = FROLLIC * FROBNITZ
40 PRINT FROGS
Output: 144
Re:Looks more like assembler to me... (Score:3, Informative)
No, it's because in early Fortran compilers integer variables were letters from I to N (because they are INteger, see?).
So, in Fortran you would start a loop using the first available integer variable, i, and then j, k and so on.
How that was carried on to other languages is a mystery....
Re:Looks more like assembler to me... (Score:3, Informative)
Obviously you aren't an old-school BASIC guy. That's how it worked. If you wanted to do anything fast, you wound up rolling a bunch of machine language inside a BASIC control loop.
Next... (Score:2, Interesting)
Re:Next... (Score:3, Interesting)
http://linux.umbc.edu/~mabzug1/bash-httpd.html
Re:Next... (Score:5, Interesting)
%tcpserver 127.0.0.1 80
--- webserver.rc ---
#!/usr/local/bin/rc
root = '/home/www/document_root'
fn echo_response {
echo 'HTTP/1.1 ' ^$response
}
fn echo_date {
echo -n 'Date: '
}
fn echo_content_type {
echo -n 'Content-Type: '
}
fn echo_content_length {
echo -n 'Content-Length: '
}
fn respond {
echo_response
echo_date
echo 'Server: rc shell'
echo_content_length
echo_content_type
echo 'Connection: close'
echo
}
ifs = '
'
for (request in `{echo -n}) {
url = $request(2)
file = `{echo $url | sed 's/http:\/\/[^\/]*//' | tr -d \012}
path = $root ^$file
echo $path
if (/bin/test -e $path) {
response = '200'
} else {
response = '404'
path = $root ^'/404.html'
}
respond
}
Parent
oops, wrong version (Score:5, Interesting)
sadly I posted a slightly wrong version
here's the one that works
http://www.proweb.co.uk/~matt/rc/webserver.rc
it's only a toy, of course.
http://server/../../../../../../etc/passwd
will get you the passwd file
Parent
Source code has no copyright notice (Score:5, Funny)
Not really that uncommon (Score:2, Informative)
Just tell me how... (Score:2)
I must be getting rusty. (Score:5, Funny)
data statements (Score:5, Informative)
Sweet Deal (Score:2)
What makes me laugh is that when I was using BASIC, I was printing a man to the screen as he went through the positions of a jumping jack. Clearing the screen after each position made it seem as though he was doing a jumping jack be
EhBASIC (Score:5, Funny)
EhBasic? (Score:4, Funny)
Not new (Score:4, Informative)
it isn't complete (Score:5, Funny)
There should be a prize... (Score:3, Interesting)
When is a 404 not a 404? (Score:4, Insightful)
34041 DATA "<HTML><HEAD><TITLE>Error 404</TITLE></HEAD><BODY BGCOLOR=#"
is it just me who's spotted that the 404 page isn't really a 404?
This explains everything (Score:3, Funny)
Re:how? (Score:3)
Re:WOW! And they said.. (Score:3, Interesting)
$ ls | grep basic
bwbasic/
gnomebasic/
pbasic/
wxbasic/
Re:WOW! And they said.. (Score:3, Funny)
Screw that - I want a version of FreeBSD written in BASIC
Re:Are you kidding? (Score:5, Insightful)
I would agree it still lives, but disagree about your reasons...
VB strips away all the simplicity normally present in BASIC, in that if you know basic, you don't necessarily know VB (very similar to C vs JAVA... They have very similar atomic statements, but the different paradigm makes proficiency in one not map 1-to-1 to the other).
VB excels in making pretty GUIs under Windows. I have yet to find a language that makes creating a spiffy user interface anywhere *near* so easy. People rave about JAVA for GUIs, but I would say that, line-for-line, it takes just as much work as using pure Win32. Tk does fairly well, as long as you like the system default of everything, but if you want more control, it makes you jump through all sorts of unpleasant hoops. But VB... Just no way to beat its level of GUI-oneness.
Unfortunately, it crawls when it comes to execution speed. I remember writing an app for a professor back in college, did nothing but text processing and a few simple stats to compile student evaluation surveys. Running through a list of only 30-50 students took almost two minutes. Incidentally, I prototyped it in C (but he wanted a spiffy GUI, and I hadn't yet mastered raw Win32), and the same thing would finish in well under a second.
Parent
BBC Basic was like that (Score:5, Interesting)
definable functions
re-entrant procedures
http://www.bbcbasic.com/
Sophie Wilson did a great job and did anyone at school in the UK who was interested in computing the biggest favour of all - she gave us the gift of learning structured programming from day 0
Parent