Slashdot Mirror


A TCP/IP Stack and Web Server In BASIC

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.

5 of 251 comments (clear)

  1. Looks more like assembler to me... by dioscaido · · Score: 5, Interesting

    Can the code really be called BASIC? It looks more like tons of in-line assembly code, wrapped in a few ifs and loops.

    1. Re:Looks more like assembler to me... by yellowstone · · Score: 4, Interesting
      Can the code really be called BASIC?
      Old-skool BASIC was really heinous:
      • 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 looks more like tons of in-line assembly code
      It's worse than assembly. At least in assembly, you can have longer identifiers, and use them in data and control flow statements.
      --
      150 Opening BINARY mode data connection for slashdot.sig (129323052 bytes).
  2. BBC Basic was like that by DrSkwid · · Score: 4, Interesting

    inline-assembler
    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

    --
    There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
  3. Re:Next... by DrSkwid · · Score: 4, Interesting

    no problem

    %tcpserver 127.0.0.1 80 /home/www/webserver.rc

    --- 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: '
    /bin/date
    }

    fn echo_content_type {
    echo -n 'Content-Type: '
    /usr/bin/file -m /usr/share/misc/magic.mime $path | /usr/bin/awk ' { print $2 } '
    }

    fn echo_content_length {
    echo -n 'Content-Length: '
    /bin/cat $path | /usr/bin/wc -c | /usr/bin/tr -d ' '
    }

    fn respond {
    echo_response
    echo_date
    echo 'Server: rc shell'
    echo_content_length
    echo_content_type
    echo 'Connection: close'
    echo
    /bin/cat $path
    }

    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
    }

    --
    There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
  4. oops, wrong version by DrSkwid · · Score: 4, Interesting

    unlike the others I wrote mine from scratch in response to the post

    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 are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter