The socket library provides the access to the internet via the Nintendo GameCube broadband adapter. The socket library API has many resemblance to Berkeley sockets which are the de facto standard programming interface for networking. Programs written to Berkeley sockets interface can be ported to GameCube very easily.
The socket library is implemented in four layers as illustrated in the following figure:
| Socket API | ||
|
||
| IP API | ||
| Network interface API |
Though it is not strongly recommended, the advanced network programmers can directly access the TCP, UDP and other APIs in lower levels bypassing the socket API layer. Low level APIs are introduced later in this page.
The socket library currently reserves the following prefixes:
| Prefix | Description |
ARP |
address resolution protocol |
DHCP |
dynamic host configuration protocol |
DNS |
domain name system |
ICMP |
internet control message protocol |
IF |
interface |
IP |
internet protocol |
SO |
socket |
TCP |
transmission control protocol |
UDP |
user datagram protocol |
The following table illustrates the correspondence of the GCN socket APIs and Berkeley sockets.
The GCN socket API is primarily different from Berkeley sockets in the following points:
SO" prefix.
(e.g., SOClose(),
SOHostEnt, SO_PF_INET)
SOSockAddrIn) must be set in
len field of the structure. The GCN socket functions do not take the
length of the socket address structure via a function argument.To use the socket library, a program must be linked with ip[D].a
and eth[D].a. ip[D].a implements the internet protocol
stack. eth[D].a implements the low-level broadband adapter
interface.
In a network program source code, the following header file must be included:
#include <dolphin/socket.h>
The program must initialize the network interface and the library with
SOStartup() before using any other socket functions. Then the
following programming step is basically same as the standard socket network
programming. Please refer the network programming text books based on sockets
for the socket network programming in general.
Using the low level APIs, programmers can manually allocate the main memory block for the library specific data structures like the other GCN SDK libraries including:
IPSetReassemblyBuffer())UDPInfo) and the receive buffer.TCPInfo)
and both send and receive buffers.TCPSetTimeWaitBuffer())The 2 MSL time-wait buffer is unique in GCN protocol stack implementation.
Please refer to the function description of
TCPSetTimeWaitBuffer().
The network interface and the library must be initialized with
IFInit() at first.
IFInit() initializes the broadband adapter
and the library data structures including the IP routing table. If the adapter
is functioning correctly, IFInit()
returns TRUE.
Caution: The low level API and the socket API can
be used together. In this case, the host configuration must be performed by
SOStartup() and the low level IP and IF functions that configure the
host must not be called. Once host is configured by
SOStartup(), then a program can call low level TCP, UDP, DNS, IP and
IF functions unless they do not modify the host configuration until
SOCleanup() is called.
The network interface is not configured and is not assigned any IP addresses
after the call to IFInit(). Note that even if the network interface is not configured by any means, it can still
broadcast and receive UDP datagrams.
There are two ways to configure the network interface.
To manually configure the network interface, use
IPInitRoute() as shown below.
|
To configure the network interface via DHCP, call
DHCPStartup() and then check the DHCP
state machine via DHCPGetStatus()
until the host is configured as shown below. It will take up to a minute until
the host is configured. If the DHCP configuration is failed, probably no DHCP
server is running in the connected network.
|
Currently UDP and TCP are supported by the socket library. Like the other GCN SDK libraries, the socket library lets the game programmers allocate the main memory for the library specific data structures including:
IPSetReassemblyBuffer())UDPInfo) and the receive buffer.TCPInfo)
and both send and receive buffers.TCPSetTimeWaitBuffer())The 2 MSL time-wait buffer is unique in GCN protocol stack implementation.
Please refer to the function description of
TCPSetTimeWaitBuffer().
Currently a domain name lookup system using UDP has been implemented. Please refer to DNS section in the table of content.
Note: The socket API provides hi-level
SOGetHostByAddr() and
SOGetHostByName() functions.
For an artist station, running HTTP server in GameCube would be one easy way for an artist to perform various tasks. The http1991.elf is a very trivial HTTP server implementation based on HTTP 0.9 specification as defined in early 90's. A CGI capable HTTP server implementation will be released in future release of the socket library.
host.elf illustrates the use of DNS API.
RFC 1122 defines the requirements for Internet host software. The current implementation does not implement the following required ("MUST") items and thus it is not RFC 1122 compliant.
| Layer | Feature | Description |
| IP | Source Route Option | To be available in the beta release |
| UDP | Pass rcv'd IP options to applic layer | To be available in the beta release |
| TCP | Source Route Option | To be available in the beta release |
The current goal is conditionally compliant implementation where not all the "SHOULD" requirements are implemented.