FETCH [/H] [http://]host[:port][/path]
Displays a web page: FETCH connects to host (on port 80, unless port is given), sends an HTTP/1.0 request for path (or /, if there’s none), and displays the body of the response. With /H, FETCH displays the entire response, including its status line and headers. For example:
FETCH basicdos.com/LICENSE.txt
MIT License
Copyright (c) 2020-2026 Jeff Parsons
...
The body is written exactly as it arrives, so redirecting FETCH’s output saves a copy of any file, text or binary (eg, FETCH basicdos.com/LICENSE.txt > LICENSE.TXT). Since a colon followed by other characters separates commands on a command line, an address with a port must be quoted (eg, FETCH "basicdos.com:80/LICENSE.txt").
FETCH opens a TCP: connection, and the first program that does so loads the TCP driver, TCP.SYS, from EXT\SYS, which stays loaded until the system restarts. If CONFIG.SYS has loaded NE2000.SYS, the driver for an NE2000 network adapter, TCP.SYS sends and receives the connection’s packets on the adapter, in Ethernet frames. Otherwise, it uses COM2 at 115200 baud (as SLIP frames), but only while a connection is open, so other programs can use COM2 in between: if a Hayes-compatible modem answers on COM2, the driver dials the network (555-0100), and hangs up when the last connection closes; otherwise, the other end of COM2 must be the network itself.
Either way, the other end is a gateway that serves a small network of its own: a name server, and a web server whose pages for its own host names (basicdos.com and www.basicdos.com) are its own; any other host name is found too, and its pages are the Internet Archive’s captures of them, from the date that the request asks for (see WEB), or else the gateway’s own date. It also has an FTP server, ftp.bitsavers.org, a read-only, anonymous view of bitsavers.org’s archive of old computer software and documentation: its directories are the site’s directories, and its files are read from the site as an FTP client asks for them, in passive (PASV) or active (PORT) mode; names are found without regard to case, and the sizes that a directory listing shows are approximate (the exact size of a file is reported when it’s transferred). FTP gets its files, and so can an FTP client for DOS (eg, KA9Q NOS, which a BASIC-DOS hard disk has in TOOLS\BIN). The gateway, gateway.js, is a Node.js program in the BASIC-DOS repository’s tools folder, which reads the PC’s data from its standard input and writes its own to its standard output; its web server’s pages are files in a directory (by default, the BASIC-DOS web site that Jekyll builds in _site; a path that names a directory gets its index.html).
In PCjs, pc.js connects the gateway to the machine in one of three ways: directly to COM2, through a modem on COM2 (whose phone book gives the gateway the number 555-0100), or through an NE2000 that pc.js adds to the machine (whose CONFIG.SYS must load NE2000.SYS):
pc.js ibm5160 --com2="node tools/net/gateway.js"
pc.js ibm5160 --modem="555-0100=node tools/net/gateway.js"
pc.js ibm5160 --ne2000="node tools/net/gateway.js --ethernet"
The gateway’s options are --root=directory (the web server’s pages), --hosts=name,name… (the host names whose pages are its own), --era=date (its own date for other hosts’ pages, as the Internet Archive writes dates, eg, 1998 or 19961201; 1998 by default), --noweb (no other hosts), --ftpsite=url (the site whose files the FTP server has; https://bitsavers.org/ by default), --ftphost=name (the FTP server’s name; ftp.bitsavers.org by default), --noftp (no FTP server), --ethernet (for an NE2000), and --log=file (a log of its connections and requests). On the 20Mb Drive demo pages, the page itself is the gateway, its own pages are the site’s, and other hosts’ pages (and the FTP server’s files) come through the site’s proxy for the Internet Archive and bitsavers.org (since their pages can’t be read by other web pages directly): on the PC XT and PC AT, it answers the modem on COM2 (which also has Claude’s number), and on the DeskPro 386, it’s on the machine’s NE2000 (the hard disk’s CONFIG.SYS loads NE2000.SYS, which the other machines, with no adapter, don’t keep). The Networking demo pages work the same way, with a diskette that has FETCH.BAS, WEB.BAS, TCP.SYS, and NE2000.SYS (which the other demo diskettes don’t have): on the PC and PC XT, through the modem, and on the PC AT and DeskPro 386, through an NE2000.
If the host can’t be found, refuses the connection, or there’s no TCP driver (or no COM2, without a network adapter), FETCH displays Unable to connect to host and sets ERRORLEVEL to 68, and if the host (or a modem’s call) doesn’t answer within 5 seconds, it displays Device timeout and sets ERRORLEVEL to 24. If the web server can’t find the page, FETCH displays Unable to find path and sets ERRORLEVEL to 53, and for any other error that the server reports, FETCH displays the status (eg, 501 Not Implemented) and sets ERRORLEVEL to 1. An unknown switch, or a missing or invalid address, is a usage error.
Source: FETCH.BAS
Copyright (c) 2020-2026 Jeff Parsons Released under MIT License