Skip to content
Permalink
1eb01e12ac
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
51 lines (41 sloc) 1.04 KB
#ifndef DATA_SYNC_THREAD_HPP
#define DATA_SYNC_THREAD_HPP
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdlib.h>
#include <stdio.h>
#include "Attribute.hpp"
#include "CMakeConfig.h"
// Need to link with Ws2_32.lib, Mswsock.lib, and Advapi32.lib
#pragma comment (lib, "Ws2_32.lib")
#pragma comment (lib, "Mswsock.lib")
#pragma comment (lib, "AdvApi32.lib")
/*
This class contains the thread for communicating back and forth along a socket to sync attributes
*/
class DataSyncThread
{
private:
SOCKET sock;
HANDLE hThread;
DWORD dwThreadId;
bool continueThread = false;
public:
DataSyncThread(SOCKET s) { sock = s; };
// Synchronous functions
void threadRuntime();
static DWORD threadInit(LPVOID pThreadArgs)
{
DataSyncThread* pDataSyncThread = (DataSyncThread*)pThreadArgs;
pDataSyncThread->threadRuntime();
return NULL;
}
int recvBytes(void* buffer, size_t numBytes);
// Async control
void startComms();
bool stopComms();
int connectToAlgorithm(char* serverName);
};
#endif