I need a class that will communicate with my server and will retrieve data from it.
The communication protocol is propietary but very simple, you send one struct, get one back, what it does is give me the category of a web site, so the class will send the URL and will receive a reply and report the reply or failure.
The class will try to reuse sockets and not connect per each connection to the server.
Also I need to be able to specify a timeout on the wait, if the timeout passed, it should stop and return an error.
You can see how the structs of the protocol looks like (more or less):
//The request
typedef struct _RequestData
{
//Constant header
unsigned char ucTotalSize;
unsigned char ucVersion;
unsigned char ucFlags;
//Now there will come two null terminated strings, one of the ID, one the url
char* pID;
char* pURL;
} RequestData;
//The reply data
typedef struct _ReplyData
{
//Constant header
unsigned char ucTotalSize;
unsigned char ucVersion;
unsigned char ucStatus;
//Now there will come two terminated string of the reply
unsigned char ucCategories[4];
unsigned char ucExtraAvailable[4]; //This will only come back in version1
} ReplyData;
So when I create the class I will give it the ID to send in the request, and then per request I will provide the URL, and timeout, and the class will return timeout, error or the result.