Software

From Spectrum
Revision as of 21:51, 3 June 2008 by Winston (talk | contribs)
Jump to navigation Jump to search

There are three main categories of software for the Spectranet; library code (i.e. the socket library and peripheral functions), utility code - things like a configuration user interface, and application code - some of which will be burned into ROM. Current plans call for the following:

The Basics

Library Reference

The socket library

The most important part is probably the socket library. This will provide a subset of the BSD socket library. The plans are for three equivalent libraries: an assembler library, a C library based around the Z88DK, and a BASIC library. The C library will essentially be a wrapper around the assembler library (with a few extra pieces of error checking, which for asm users will be left up to the programmer).

The rationale for using the BSD socket interface (rather than just a simple wrapper around the W5100's TCP offload engine) is to provide an interface that's familiar to any programmer who has written net code, and also (importantly) to provide hardware independence. The BSD library has worked well for pretty much every network device that speaks TCP/IP, so I know if for some reason, a chip other than the W5100 needs to be used, or a different TCP/IP stack needs to be used, the software interface does not need to be changed - and therefore, code that people have slaved over to make the Spectranet useful won't need to be changed either.

The main functions that will be implemented for all languages are:

  • socket (HLCALL 0x3E00) - Creates a new socket.
  • bind - Binds a name to a socket (i.e. sets the port).
  • listen - Tells an open socket that it should listen for incoming connections.
  • accept - Accepts a connection that has arrived on a listening socket.
  • connect - Connects to a remote host.
  • recv - Receives data from a socket (SOCK_STREAM)
  • send - Sends data to a socket (SOCK_STREAM)
  • recvfrom - Receives a message from a socket.
  • sendto - Sends a message to a socket.
  • poll - Checks for new data or a status change on a socket.
  • close - Closes a socket.

Utility code

Certain utilities will be provided in the ROM. The most important one will be the one that allows the user to configure the device. This will provide a simple user interface for setting the IP address, netmask and gateway, and hardware address (if it needs changing from the one put in ROM on initial programming; unfortunately, joining the IEEE to get Ethernet addresses assigned to the project is prohibitively expensive).