The proceedure for clients and servers to interact is that the client
sends a packet, and the server accepts and processes it.  The lower
level routines make sure the packets get there and get there in order.
If any responce is in order, there is allways a responce, so you have
to keep a list of commands sent that havn't been responded to yet, and
when the responce comes deal with it and forget the command in question.
(You could just display the response when it comes in.)

The list of things that can be sent is available in the files client_pack,
sever_pack and appl_pack.  It is currently ready to be coded with the
possible exception of the /senddata command, which I'm not sure about yet.
The CDS routines that you need to use are below.  I list the comments and
what each routine is called with, non-ansi style.
 
short CDS_get_next_send(sendfirst,rtvl)
/* This is a routine that is called from outside the protocal.  What
   it does is return a pointer to the next item that is ready to be sent
   from the sendlist that is passed to it.  It checks down the first
   CDS_SEND_BUF items and gets the first one that has either timed out
   since it's last send, or has not been sent (which has a timesend == 0.)
   It puts the pointer in rtvl, and returns -1 if the connection has timed out.
*/
struct CDS_send_list *sendfirst,**rtvl;

 
short CDS_send_this (s,element)
/* This function is externally callable.  It does the actual sending
   of a packet that is ready to send.  If it's an ack packet we remove
   it from the send list as well, as ack packets do not have to be acked.
   It checks to see if it can send something without blocking first, and
   if it can't, it returns a -1. If it sends, then it returns 0.
*/
int s;
struct CDS_send_list *element;
 
int CDS_makesocket(sockname)
/* This function creates and returns the number that corresponds to
   a socket.  It randomly chooses a socket port based on the time.  It
   tries 50 times to secure a port, and then gives up, returning -1.
*/
struct sockaddr_in *sockname;
 
short CDS_do_recieve  (s,upfirst,get_pointers)
/*
   This routine is called from outside CDS.  It is the routine that deals
   with all of the aspects of recieving a packet.  First it checks to see
   if it can read first, and if nothing can be read, a -1 is returned.
   Next the packet is read  into the system, then if it's reference number
   is corrupt, we discard it.  If it's an ACK packet we process it specially.
   Otherwise we check to see whether or not the packet can be accepted.
   If it's the correct packet we send it up and see if any others are to
   be sent up.  If it's not correct we try and add it to the list of
   packets recieved out of order. If we can't even do that, we discard it.

   For ack packet's if we ack a packet labelled "last packet" then we return
   a -2 to indicate it's time to close up shop.
*/
int s;
struct CDS_up_list *upfirst;
short (*get_pointers)();
 
void CDS_add_to_send(s,buf,len,to,flags,get_pointers)
/*
  This is the outside interface to the CDS_add_pack routine.  We pass
  it the items described below.  It uptains a recfirst and a sendfirst
  item to use when calling the routine, and just calls them.  
*/
int s;                   /* Socket to send things out of */
char *buf;               /* Data buffer */
short len,flags;         /* length of data, flag of whether last or not */
struct sockaddr_in *to;  /* Address to send things to */
short (*get_pointers)(); /* function to turn address into list pointers */

void CDS_ping(s,to,get_pointers)
/* 
  This function adds a ping a given address's list of things to send.
  It is externallly callable.
*/
int s;
struct sockaddr_in *to;
short (*get_pointers)();
