THE VIRTUAL TO2026 / EXTENSIONS / EXT 26-103

The network interface.

The EXT 26-103 module adds the N: device. In the spirit of FujiNet, the network opens like a file: a web page is read line by line, data goes out as a POST, a WebSocket channel exchanges messages live. BASIC 2026 adds what it takes to read JSON.

TO2026 · EXT 26-103NETWORKHTTP · JSON · WSSwitch the power offbefore plugging in.N:
Reference
TO2026 · EXT 26-103
Module
Network interface
Chip
N:
Port
EXT 26-112 extension port, beside the screen
Plugging in
tick the module in EXTENSIONS, on the Explore the machine page
  • PROTOCOLSHTTP(S)

    GET and POST, plus WebSocket (ws:// and wss://)

  • DATAJSON

    path extraction: "vent.vitesse", "jours[1].nom"

  • ACCESSN:

    like a file, from both BASICs

  • GATEWAYNET PROXY

    for sites that refuse calls from another origin

01 / WHAT IT DOES

The network, like a file.

N: is a device, just like a disk drive: OPEN "I",#1,"N:https://…" downloads the page when opened, then LINE INPUT #1 reads it until EOF. For writing, what PRINT # writes goes out as one POST request when the channel is closed. With a ws:// or wss:// address, each written line goes out as a message and each read waits for the next one.

A browser cannot open a raw TCP connection: HTTP goes through fetch, and WebSocket through the object of the same name. A site that refuses calls from another origin (CORS) is reached through a gateway, set with NET PROXY; the gateway sees the requests go by, so it must be trusted. Received text is converted for the machine: accented letters become those of the TO2026, other characters question marks.

02 / IN BASIC

Read, send, listen.

STATEMENTEFFECT
OPEN "I", #n, "N:https://…"reads a page like a file (LINE INPUT #, EOF); BASIC 128 knows it too
OPEN "O", #n, "N:https://…"what PRINT # writes goes out as a POST on close
HTTP$(adresse$ [, corps$])a request in one call; with a body, a POST (JSON if the body starts with { or [)
HTTPSTATUSthe HTTP code of the last response (200, 404…)
JSON$(texte$, chemin$) / JSONLENa value from a JSON text / the number of items in a list
NET OPEN / SEND / RECEIVE / CLOSEa WebSocket channel; NETSTATUS, ON NET CALL
NET PROXY préfixe$routes every request through a gateway

The response is simulated for checking, at https://api.exemple.org/meteo.

PROGRAM
t$ = http$("https://api.exemple.org/meteo")
print "code"; httpstatus
print json$(t$, "ville"); " :"; val(json$(t$, "temp")); "degres"
for i = 0 to jsonlen(t$, "jours") - 1
  n$ = trim$(str$(i))
  print json$(t$, "jours[" + n$ + "].nom"); val(json$(t$, "jours." + n$ + ".max"))
next
ON SCREEN
code 200
Sofia : 12.5 degres
lundi 14
mardi 16

03 / MODULE REMOVED

A cable you unplug.

Removed from the extension port, the EXT 26-103 module cuts the machine’s HTTP requests: HTTP$ and OPEN "N:" have no network and answer Network Error. The other machine features that talk to the site, like AI ON, say so too: “Extension réseau N: retirée”. Disk 2, the BBS and the ProAdmin sign-in use other paths and stay available.