Skip this layer if you really want to use Armagetron's networking system
fast; it contains details you do not need to know from the start.
This layer is responsible for sending raw data packets to other computers.
The files net_anet.h,net_sysdep.C,net_udp.C and
net_wins.C are responsible for it;
they are written in pure C.
net_anet.h is the header file with the declarations visible to
layer two, and net_systep.C just includes the real
implementation from net_udp.C or net_wins.C depending
on the system Armagetron is compiled for.
represented by integers: in analogy to file descriptors,
all network IO is done
through sockets. Every client has one socket where all the messages to/from
the server are sent/received through. The server has one listening socket for
the messages from new clients, and one IO socket for each client.
(With the UDP protocol, all these sockets are really identical, as there is
no such thing as a connection and no need/possibility to assign a connection
to the sockets.)
Function list
(only the functions layer two actually uses are mentioned)
On the server, this checks if there are any new connections
from clients wanting to join the game. Returns a socket ready to receive
the newcomer if there is one, or -1 if not. In case of the UDP protocol,
even the messages from the known clients are caught by this function
(as there is no way to distinguish new and old connections with UDP), so layer
two needs to do some extra checks with this function.
Fills *addr with the information necessary to reach the server
name (containing the IP address in numerical notation or the
hostname);
the port number is set to net_hostport=4532 to match the port
the server listens on.
Sends len bytes of data from buf through the socket
sock to the peer identified with *addr. A connection
has to be established before with ANET_Connect().
Reads up to len bytes from the connection associated to
socket sock and stores them in the buffer buf.
(If a connectionless protocol like UDP is used and the socket is a listening
socket, this can mean ANY data coming in at the port the socket listens on...)
The sender's address is stored in *addr, the number of actually
read bytes is returned (Zero means no data was received.)