Graphics Reference
In-Depth Information
//Threading info
#define MAX_THREADS 2
#define BUF_SIZE 255
DWORD WINAPI SendDataThreadFunction(LPVOID lpParam);
DWORD WINAPI ReceiveDataThreadFunction(LPVOID lpParam);
void ErrorHandler(LPTSTR lpszFunction);
//Sample custom data structure for threads to use.
//This is passed by void pointer so it can be any data type
//that can be passed using a single void pointer (LPVOID).
typedef struct MyData {
int val1;
int val2;
} MYDATA, *PMYDATA;
MyDataStruct ds, dr;
DWORD WINAPI SendDataThreadFunction(LPVOID lpParam)
{
XNet* xnet = new XNet();
xnet->init(CLIENT, 64000, UDP, “localhost”);
while(1) //Keep the thread alive
{
xnet->sendData(ds);
printf(“SendDataThreadFunction:%f\n”, ds.data[0]);
}
return 0;
}
DWORD WINAPI ReceiveDataThreadFunction(LPVOID lpParam)
{
XNet* xnet = new XNet();
xnet->init(SERVER, 64001, UDP);
while(1) //Keep the thread alive
{
dr.data[0] = xnet->receiveData().data[0];
dr.data[1] = xnet->receiveData().data[1];
}
return 0;
}
PMYDATA pDataArray[MAX_THREADS];
DWORD dwThreadIdArray[MAX_THREADS];
HANDLE hThreadArray[MAX_THREADS];
#endif
std::ofstream logfile;
//—————————————————————————————————————————————————————————————————————————
//Entry point to the program. Initialises everything and goes into a
//message processing loop. Idle time is used to render the scene.
//—————————————————————————————————————————————————————————————————————————
int main(void)
{
logfile.open (“data.log”);
long startTime = time(NULL);
Search WWH ::




Custom Search