#include <stdio.h>
#include "cclient.h"
// don't forget to add cbase.cpp and cclient.cpp to your project

int main()
{
   cbase* client=new cclient("127.0.0.1",12345);
   // create client and connect to 127.0.0.1:12345

   if (!client->connected()) printf("Could not connect!\n");
   // if connection is established connected() returns 1 else 0

   else
   {
      char buffer[256]="Packet from client";
      // single packet can be up to 255 bytes long

      client->write_packet(0,buffer);
      // first parameter is ignored on client side
      // client can only send packets to the server

      client->update();
      // sending and receiving is actually done here

      while (client->read_packet(buffer)>0)
      // as long as packets are available
      printf("Server sent '%s'.\n",buffer);
      // read_packet() returns source id or 0 if no packet is available
   }

   delete client;
   // disconnect and delete client

   return 0;
}
