Tutorial 1: A High Level View
Adapted from Spectranet: Tutorial 1.
The Spectranet is more than an Ethernet interface. It combines networking hardware, CPLD bus logic, paged memory, and ROM library code so Spectrum programs can use network sockets in a style similar to other systems.
Spectranet layers
The classic stack can be viewed in layers:
- W5100 Ethernet hardware, including PHY, MAC, and IP offload engine
- CPLD glue logic, which handles paging and traps calls intended for Spectranet
- socket library and utility routines in flash ROM
Assembly programs call the ROM through indirect entries defined by spectranet.inc. C programs use lightweight z88dk wrappers that translate C calling conventions into the registers expected by the ROM routines.
Protocols
The classic socket library supports TCP and UDP.
TCP provides a reliable byte stream. It is useful for protocols such as web requests, FTP-style transfers, IRC, SSH-like streams, and filesystems that want ordered reliable data.
UDP sends individual datagrams. Delivery and ordering are not guaranteed, so application code decides how to handle loss, duplication, timeouts, and stale messages. UDP is useful for DNS, DHCP, some games, and protocols where a delayed packet is no longer useful.
The hardware can maintain only a small number of TCP sockets at once. UDP can communicate with many remote systems through fewer local resources, provided the program tracks remote addresses itself.
Next step
The next practical example is a simple TCP server.