A TCP/IP Stack and Web Server In BASIC 251
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.
Looks more like assembler to me... (Score:5, Interesting)
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.
Re:Looks more like assembler to me... (Score:2, Interesting)
Next... (Score:2, Interesting)
interesting (Score:1, Interesting)
Re:WOW! And they said.. (Score:3, Interesting)
$ ls | grep basic
bwbasic/
gnomebasic/
pbasic/
wxbasic/
Re:Next... (Score:3, Interesting)
http://linux.umbc.edu/~mabzug1/bash-httpd.html
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
Re:Looks more like assembler to me... (Score:5, Interesting)
Re:Damn (Score:2, Interesting)
I'd probably agree with you on that one.... but it's interesting to note that many of the commonly-criticized features of Basic were the result of memory-kludges and featuritis, that the original designers of Basic did not approve of at all (according to their book 'Back to Basic').
Unfortunately, I don't have the book to hand to check out the details, but here's a link [amazon.com] to it anyway.
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
}
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
There should be a prize... (Score:3, Interesting)
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
PowerBASIC (Score:2, Interesting)
I use it in conjunction with .NET and ANSI C. Check out their company history [powerbasic.com] for some background then take a look at the delicious capabilities of their Windows [powerbasic.com] and Console [powerbasic.com] compilers.
They also have a kick-ass DOS Compiler [powerbasic.com] that has put dinner on my table for years. As we know, many people are still using DOS and DOS-mode apps every day.
When looking at PowerBASIC you have to get rid of any preconcieved notions of BASIC or how it has been implimented in the past. PowerBASIC is a dream to use, has a huge community, and compilers smaller and faster than most ANSI C programs I've seen. Also, check out their partial client list [powerbasic.com] - you'll be in good company.
No, I do not work for them. I am a loyal customer and a geek that loves cool stuff. PB delivers.
BASIC Webserver (Score:2, Interesting)
Re:Looks more like assembler to me... (Score:2, Interesting)
Is that why all loops in any language in any source code seem to use i and j?
I know I do it, and I know I (sh|c)ould use something like $counter, but I've seen i and j so many times in code snippets, it's become almost second nature.
Re:Looks more like assembler to me... (Score:1, Interesting)
I'm going to take a wild guess and assume that you've never used "Integer BASIC" on the Apple ][. No, I don't mean the Apple][+ or the Apple ][e or the special Wozniak-autographed Apple ][gs. I mean the Apple ][ that came with 16 kB of RAM and required you load your interpreter into a "language card". And required you to buy an "80-column card" if you didn't like working in 40 columns of text.
Again, not all versions of BASIC had this. The TI99-4/A BASIC dialect did not allow you to do this. The part inside the DIM statement had to be a constant. I know; I tried it and was disappointed when I realized AppleSoft BASIC allowed it but TI BASIC didn't.