include(head.html.m4) define(SECTION,lower) include(navbar.html.m4) TITLE(Layer one: protocol abstraction)
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.
net_hostport=4532[)
and can be queried by]
ANET_CheckNewConnections.)
CODEITEM(checknewconnections,Socket ANET_CheckNewConnections (void);,
[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.
])
CODEITEM(getaddrfromname,[int ANET_GetAddrFromName
(const char *name, struct sockaddr *addr);],[
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.)
CODEITEM(connect,ANET_Connect(Socket s,struct sockaddr *addr);,[
Opens a connection to the computer given by ]addr[ through
the socket] s.
[As UDP is a connectionless protocol, this does not do
anything currently.])
CODEITEM(write,int ANET_Write (Socket sock, const byte *buf, int len, struct sockaddr *addr);,
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().)
CODEITEM(read,int ANET_Read (Socket sock, byte *buf, int len, struct sockaddr *addr);,
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.)])
CODEITEM(addrtostring,char *ANET_AddrToString (const struct sockaddr *addr);,[
Returns the information from ]addr[ in human readable form.])
CODEITEM(addrcompare,int ANET_AddrCompare (struct sockaddr *addr1, struct sockaddr *addr2);,
Checks whether *addr1 and *addr2 [are the same
computer (ignoring the port number). If they are, 0 is returned, -1 if not.])
CODEITEM(getsocketport,int ANET_GetSocketPort (struct sockaddr *addr),
Returns the port number from *addr.)
CODELISTEND
include(sig.m4)
include(navbar.html.m4)