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.
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
R *this* FRFC. (Score:5, Informative)
Re:R *this* FRFC. (Score:2, Funny)
Re:Down in three seconds flat (Score:5, Funny)
Here [169.254.226.132] you go
Re:Down in three seconds flat (Score:5, Funny)
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!
Re:Down in three seconds flat (Score:5, Funny)
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, Funny)
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:2)
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
Re:How long til it gets slashdotted? (Score:2)
slashdotting == regular page load when you are at
So it really doesn't matter. The first time you test it, you HAVE effectively
Re:How long til it gets slashdotted? (Score:2)
You coull always just hide it behind a SQUID (or other such cache box).
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.
Re:To quote Zahpod Beeblebrox... (Score:2)
Just use a USB ethernet card............
And you'll get a USB adaptor for a IIe where?
Imagine.. (Score:5, Funny)
20-35 Seconds Per Page?!? (Score:5, Funny)
Cowabunga! (Score:2, Funny)
Re:Cowabunga! (Score:2)
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.
Re:Cowabunga! (Score:2)
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:2)
Re:Looks more like assembler to me... (Score:2)
Re:Looks more like assembler to me... (Score:5, Interesting)
Re:Looks more like assembler to me... (Score:2)
In some of the later ones you could GOTO a variable name. This led to some really interesting code such as:
10 LET L1=100
20 PRINT "ENTER NUMBER:"
30 READ A
40 GOTO 100 + (A * 10)
100 (blah blah blah)
105 GOTO 200
110 (blah blah blah)
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!
Re:Looks more like assembler to me... (Score:5, Informative)
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:2)
Re:Looks more like assembler to me... (Score:2)
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: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:2, Insightful)
Guess only BASIC purist will cry foul at this
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
}
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
Re:Next... (Score:2)
I don't think that's gonna work. All you can call in a batch file is commands within your interpreter (usually command.com or 4dos.com) and exec files (*.com, *.bat, *.exe and others in windows only) The first thing you would have to do is have a command interpreter that wasn't a single user POS. Also, dos doesn't exactly have an easy way to talk tcp/ip or open a socket.
I guess you could possibly write a quick basic program and run it in dos, but you are likely to n
Re:Next... (Score:2)
Writing a DOS batch webserver is definately possible. To get batch to get to the network, either a DOS port of tcpserver (used in a few weird webserver implementations, including a few in bash and sh as the means of doing tcp/ip) or inetd.
Re:Next... (Score:2)
Source code has no copyright notice (Score:5, Funny)
Re:Source code has no copyright notice (Score:2, Informative)
Not really that uncommon (Score:2, Informative)
Re:Not really that uncommon (Score:2)
Re:Not really that uncommon (Score:2)
Condemning today's BASIC's because they are much advanced over their 1970's predecessors is equivalent to condemning keyboards and video displays for replacing punch cards.
Re:Not really that uncommon (Score:2)
I'll agree that most commercial shrink-wrapped applications aren't written BASIC, but those apps represent a small segment of the market compared to "scripting, shareware and in-house apps". (If the shrink-wrapped market was
Just tell me how... (Score:2)
Re:Just tell me how... (Score:2)
See here [wikipedia.org] for more info.
I must be getting rusty. (Score:5, Funny)
Re:I must be getting rusty. (Score:2, Funny)
That's not being rusty, that's being normal.
Re:I must be getting rusty. (Score:2)
data statements (Score:5, Informative)
Re:data statements (Score:2)
Re:data statements (Score:2)
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)
Note to self... (Score:2)
Not new (Score:4, Informative)
it isn't complete (Score:5, Funny)
If The Open Source Crowd Invented BASIC Today... (Score:2, Flamebait)
Suppose BASIC didn't exist, and some contemporary open source developer released a full-blown compiler for a language equivalent to ANSI BASIC, or the dialect supported by PowerBasic, or even Visual Basic. Some folks, I imagine, might like what they see.
Re:If The Open Source Crowd Invented BASIC Today.. (Score:2)
Re:If The Open Source Crowd Invented BASIC Today.. (Score:2)
Somehow, I can't get rid of this image of some 19-year old sophomore slouched over a keyboard in his room in the dorm...
security vulnerability (Score:2)
Re:security vulnerability (Score:2)
Probably not that funny, anyway.
that's nothing. (Score:2)
There should be a prize... (Score:3, Interesting)
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 st
Why so "impossible"? (Score:2, Informative)
Okay, I recognize the value of doing this (as a hobbyist myself). The fortitude required to accomplish such a feat is noteworthy. However, I have noticed a strange trend in these kinds of posts on Slashdot. Why do so many people respond with comments like, "I didn't know it could be done!"?.
Technically, all of these languages are mathematically reducible to Turing machines. Thus, they are all *technically* able to perform the same tasks (ok, sure, you might have to extend your interpreter/compiler to
BASIC Webserver (Score:2, 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?
Nooooooooo (Score:2, Funny)
1248 goto 10
First Contiki, then XGamestation, and now this... (Score:2)
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
Are you kidding? (Score:2)
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.
VB not slow (Score:2)
Sloooow:
For lIndex = 1 to 10000
sLarge = sLarge & sSmall1 & sSmall2 & sSmall3
Next lIndex
As sLarge grows copying it gets more and more expensive. In this example sLarge will be copied three times as each small string gets appended in turn.
Re:Are you kidding? (Score:2)
QT Designer
Glade
Interface Builder
etc etc.
GUI Builder != VB. In fact, VB has just about the worst GUI builder still in serious use.
VB is a nightmare. It is not simple in any way at all, and leads most to produce the worst and least usable guis possible.
Execution speed wise - there are tons of gotchas that will slow you down. Messing with big strings is one. Its really not predictable unless you spend ages researching it. VB use in any area is a sign of brain damage.
Raw Win32 API is an interesting way
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:BBC Basic was like that (Score:2)
By the same token, only someone working on a very big project can appreciate OOP.
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 detail
java days and pip (Score:2)
any one remember PIP on the altair?
in any case when java came along I bet that one reason MS saw it as a threat was that between java and a browser you really did not need to have an OS at all. you just needed to have the computer wake up in java and then write the OS or l
Re:What? (Score:2)
-uso.
Re:What? (Score:2)
The Commodore 64 also had its BASIC on ROM, but it was shadowed by RAM, so you could replace it with RAM programmatically if you wanted.
Re:What? (Score:2)
BASIC interpreter hogging memory? Hell, no. Commodore 64 was based on 6510 which had a processor channel on the $00 and $01. These addresses could be used to toggle ROM banks off, like this:
LDA #%11111110; AND $01; STA $01
...turns of the BASIC ROM and you can put whatever the hell you want to the RAM bank right under it. Bit 0 for BASIC ROM, bit 1 for Kernal (sic) ROM, and bit 2 for Character ROM. Character ROM is useful unles
Re:Oh good... (Score:2, Informative)
They were slow and limited, but playing with them and extending them was a great way to learn. After those came the Small C compilers--never looked back.
Re:What next? (Score:2)